1 | <?php |
||
11 | class Day implements Entity, IteratorAggregate |
||
12 | { |
||
13 | |||
14 | /** @var DateTimeInterface */ |
||
15 | private $date; |
||
16 | |||
17 | /** @var array */ |
||
18 | private $dishes = []; |
||
19 | |||
20 | public function __construct(DateTimeInterface $date) |
||
24 | |||
25 | /** |
||
26 | * @param Dish $dish |
||
27 | */ |
||
28 | public function addDish(Dish $dish): void |
||
34 | |||
35 | /** |
||
36 | * @param int $index |
||
37 | * @return Dish |
||
38 | * @throws DishNotFoundException |
||
39 | */ |
||
40 | public function getDish(int $index): Dish |
||
48 | |||
49 | public function getDate(): DateTimeInterface |
||
53 | |||
54 | /** |
||
55 | * @param \stdClass $jsonObject |
||
56 | * @return Day |
||
57 | */ |
||
58 | public static function fromJson(\stdClass $jsonObject): self |
||
70 | |||
71 | public function getDayOfWeek(): int |
||
75 | |||
76 | public function getIterator() |
||
80 | } |
This check looks for type mismatches where the missing type is
false
. This is usually indicative of an error condtion.Consider the follow example
This function either returns a new
DateTime
object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returnedfalse
before passing on the value to another function or method that may not be able to handle afalse
.