@@ -768,30 +768,34 @@ |
||
| 768 | 768 | { |
| 769 | 769 | // If not array, return. |
| 770 | 770 | if (!is_array($timePeriods)) { |
| 771 | - if ($exception) |
|
| 772 | - throw new \Exception('Time periods format error !', 400); |
|
| 771 | + if ($exception) { |
|
| 772 | + throw new \Exception('Time periods format error !', 400); |
|
| 773 | + } |
|
| 773 | 774 | return []; |
| 774 | 775 | } |
| 775 | 776 | |
| 776 | 777 | foreach ($timePeriods as $k => $tp) { |
| 777 | 778 | // filter format, number |
| 778 | 779 | if (!is_array($tp) || sizeof($tp) != 2) { |
| 779 | - if ($exception) |
|
| 780 | - throw new \Exception('Time periods format error !', 400); |
|
| 780 | + if ($exception) { |
|
| 781 | + throw new \Exception('Time periods format error !', 400); |
|
| 782 | + } |
|
| 781 | 783 | unset($timePeriods[$k]); |
| 782 | 784 | continue; |
| 783 | 785 | } |
| 784 | 786 | // filter time period |
| 785 | 787 | if ($tp[0] >= $tp[1]) { |
| 786 | - if ($exception) |
|
| 787 | - throw new \Exception('Time periods format error !', 400); |
|
| 788 | + if ($exception) { |
|
| 789 | + throw new \Exception('Time periods format error !', 400); |
|
| 790 | + } |
|
| 788 | 791 | unset($timePeriods[$k]); |
| 789 | 792 | continue; |
| 790 | 793 | } |
| 791 | 794 | // filter time format |
| 792 | 795 | if (self::getFilterDatetime() && (!self::isDatetime($tp[0]) || !self::isDatetime($tp[1]))) { |
| 793 | - if ($exception) |
|
| 794 | - throw new \Exception('Time periods format error !', 400); |
|
| 796 | + if ($exception) { |
|
| 797 | + throw new \Exception('Time periods format error !', 400); |
|
| 798 | + } |
|
| 795 | 799 | unset($timePeriods[$k]); |
| 796 | 800 | continue; |
| 797 | 801 | } |