| 1 | <?php |
||
| 10 | class Dish implements Entity |
||
| 11 | { |
||
| 12 | |||
| 13 | /** @var string */ |
||
| 14 | private $name; |
||
| 15 | |||
| 16 | /** @var float */ |
||
| 17 | private $price; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Dish constructor. |
||
| 21 | * @param string $name |
||
| 22 | * @param float $price |
||
| 23 | */ |
||
| 24 | 3 | public function __construct(string $name, float $price) |
|
| 29 | |||
| 30 | /** |
||
| 31 | * @param \stdClass $jsonObject |
||
| 32 | * @return Dish |
||
| 33 | */ |
||
| 34 | 3 | public static function fromJson(\stdClass $jsonObject): self |
|
| 38 | |||
| 39 | /** |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | 3 | public function getName(): string |
|
| 46 | |||
| 47 | /** |
||
| 48 | * @return float |
||
| 49 | */ |
||
| 50 | public function getPrice(): float |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Specify data which should be serialized to JSON |
||
| 57 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
| 58 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
| 59 | * which is a value of any type other than a resource. |
||
| 60 | * @since 5.4.0 |
||
| 61 | */ |
||
| 62 | public function jsonSerialize(): array |
||
| 69 | } |