| 1 | <?php |
||
| 16 | class Dish implements Entity |
||
| 17 | { |
||
| 18 | |||
| 19 | /** @var string */ |
||
| 20 | private $name; |
||
| 21 | |||
| 22 | /** @var float */ |
||
| 23 | private $price; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Dish constructor. |
||
| 27 | * @param string $name |
||
| 28 | * @param float $price |
||
| 29 | */ |
||
| 30 | 3 | public function __construct(string $name, float $price) |
|
| 35 | |||
| 36 | /** |
||
| 37 | * @param \stdClass $jsonObject |
||
| 38 | * @return Dish |
||
| 39 | */ |
||
| 40 | 3 | public static function fromJson(\stdClass $jsonObject): self |
|
| 44 | |||
| 45 | /** |
||
| 46 | * @return string |
||
| 47 | */ |
||
| 48 | 3 | public function getName(): string |
|
| 52 | |||
| 53 | /** |
||
| 54 | * @return float |
||
| 55 | */ |
||
| 56 | public function getPrice(): float |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Specify data which should be serialized to JSON |
||
| 63 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
| 64 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
| 65 | * which is a value of any type other than a resource. |
||
| 66 | * @since 5.4.0 |
||
| 67 | */ |
||
| 68 | public function jsonSerialize(): array |
||
| 75 | } |