Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vumanskyi/dataobjectconvert

Convert json or yaml to php DTO or Entity
https://github.com/vumanskyi/dataobjectconvert

Last synced: 6 days ago
JSON representation

Convert json or yaml to php DTO or Entity

Awesome Lists containing this project

README

        

# Data Object Converter

The CLI tool to turn JSON and YAML objects into Data Object (PHP)

There are two types of object: entity and data transfer object.

## Usage

Convert **json** structure to php data object
```
data-object-convert json -c PersonDto "{\"name\": \"John\", \"age\": 30, \"cost\": 30.20}"
```

Result:
```
name = name;
$this->age = age;
$this->cost = cost;
}

public function getAge(): int
{
return $this->age;
}

public function getCost(): float
{
return $this->cost;
}

public function getName(): string
{
return $this->name;
}

}

```

Convert **yaml** structure to php data object

```

data-object-convert yaml -t entity -c PersonEntity "

name: John
age: 30
cost: 30.20
"
```

Result:

```
name = $name;
return $this;
}

public function getName(): string
{
return $this->name;
}

public function setAge(int $age): self
{
return $this->age = $age;
return $this;
}

public function getAge(): int
{
return $this->age;
}

public function setCost(float $cost): self
{
return $this->cost = $cost;
return $this;
}

public function getCost(): float
{
return $this->cost;
}

}
```