https://github.com/alexnguetcha/jsontoclass
https://github.com/alexnguetcha/jsontoclass
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/alexnguetcha/jsontoclass
- Owner: AlexNguetcha
- License: gpl-2.0
- Created: 2020-08-11T18:20:38.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-20T19:24:02.000Z (over 4 years ago)
- Last Synced: 2025-01-15T15:50:42.986Z (4 months ago)
- Language: PHP
- Size: 27.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JsonToClass
simple tool to create **php class** from **json file**.
#### Example:
```json
{
"class_name": "post",
"class_attrs": {
"id": {
"type": "int",
"visibility": "private"
},
"id_member": {
"type": "int",
"visibility": "private"
},
"content": {
"type": "string",
"visibility": "private"
},
"create_at": {
"type": "DateTime",
"visibility": "private"
}
}
}
``````php
$jtc = new JsonToClass(__DIR__."\\post.json");
$jtc->toFile();
```#### Output:
```php
//Post.php
name = $name;
$this->old = $old;
$this->sick = $sick;
}public function getName(): string
{
return $this->name;
}public function getOld(): int
{
return $this->old;
}public function isSick(): bool
{
return $this->sick;
}public function setName(string $name):self
{
$this->name = $name;
return $this;
}public function setOld(int $old):self
{
$this->old = $old;
return $this;
}public function setSick(bool $sick):self
{
$this->sick = $sick;
return $this;
}}
```