Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zyimm/pojo
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/zyimm/pojo
- Owner: zyimm
- License: gpl-3.0
- Created: 2024-02-02T05:03:25.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-06T08:50:01.000Z (9 months ago)
- Last Synced: 2024-10-12T06:44:57.924Z (about 1 month ago)
- Language: PHP
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP数组转为类Java POJO对象处理提高程序安全性
安装
```shell
composer require zyimm/php-pojo
```## 使用示例
```php
class DemoDto extends \Zyimm\Pojo\Pojo
{
protected $id;
protected $name;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
public function setId(int $id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getName():string
{
return $this->name;
}
public function setName(string $name)
{
$this->name = $name;
}}
$dto = new DemoBto([
'id' => 1
'name' => 'name'
])echo $dto['id']; // 1 or $dto->getId();
```