Conditions | 5 |
Paths | 6 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
40 | public function isDateAvailable() |
||
41 | { |
||
42 | $ranges = []; |
||
43 | |||
44 | foreach (['min', 'max'] as $range) { |
||
45 | $value = $this->element->getAttribute($range); |
||
46 | // If no range was set then use the original date as its value. |
||
47 | $ranges[$range] = null === $value ? $this->time : strtotime($value); |
||
48 | } |
||
49 | |||
50 | if ($this->time < $ranges['min'] || $this->time > $ranges['max']) { |
||
51 | throw new \Exception(sprintf('The "%s" is not available for choosing.', $this->date)); |
||
52 | } |
||
53 | |||
54 | return $this; |
||
55 | } |
||
56 | |||
83 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.