- Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.26, 7.4.0 - 7.4.16, 8.0.0 - 8.0.3
- object(Cookpedia\Entity)#2 (3) { ["id"]=> int(0) ["carbohydrates"]=> int(0) ["measures"]=> array(0) { } }
<?php
namespace Cookpedia;
class Entry {
private $hydrated = false;
private $data = [
'id' => 0,
'title' => null,
'latin_title' => null,
'category' => 0,
'calories' => 0,
'proteins' => 0,
'fats' => 0,
'carbohydrates' => 0,
'description' => null,
'tags' => [],
'measures' => [],
];
public function hydrate(): Entity
{
return new Entity(...array_values($this->data));
}
}
class Entity
{
public $id, $carbohydrates, $measures;
public function __construct(int $id, ?string $title, ?string $latinTitle, int $category,
int $calories, int $proteins, int $fats, int $carbohydrates, ?string $description,
array $tags, array $measures)
{
$this->id = $id;
$this->carbohydrates = $carbohydrates;
$this->measures = $measures;
}
}
$entity = (new Entry())->hydrate();
var_dump($entity);