| Total Complexity | 11 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Coverage | 81.82% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | class ProductionSeason extends Base |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var string[] |
||
| 18 | */ |
||
| 19 | protected array $_response = []; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var Performance[] |
||
| 23 | */ |
||
| 24 | protected array $_performances = []; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @throws InvalidArgumentException |
||
| 28 | */ |
||
| 29 | 4 | public function firstPerformanceDate(string $timezone = 'America/New_York'): DateTime|bool |
|
| 30 | { |
||
| 31 | try { |
||
| 32 | 4 | $timezone = new DateTimeZone($timezone); |
|
| 33 | 1 | } catch (Exception $e) { |
|
| 34 | 1 | throw new InvalidArgumentException($e->getMessage()); |
|
| 35 | } |
||
| 36 | |||
| 37 | 3 | $date = isset($this->response()['FirstPerformanceDate']) ? $this->response()['FirstPerformanceDate'] : false; |
|
| 38 | 3 | if ($date) { |
|
| 39 | try { |
||
| 40 | 2 | return DateTime::createFromFormat(' Y-m-d\TG:i:sp', $date, $timezone); |
|
| 41 | } catch (Exception $e) { |
||
| 42 | trigger_error($e->getMessage(), E_USER_ERROR); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | 1 | return false; |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @throws InvalidArgumentException |
||
| 51 | */ |
||
| 52 | 3 | public function lastPerformanceDate(string $timezone = 'America/New_York'): DateTime|bool |
|
| 53 | { |
||
| 54 | try { |
||
| 55 | 3 | $timezone = new DateTimeZone($timezone); |
|
| 56 | 1 | } catch (Exception $e) { |
|
| 57 | 1 | throw new InvalidArgumentException($e->getMessage()); |
|
| 58 | } |
||
| 59 | |||
| 60 | 2 | $date = isset($this->response()['LastPerformanceDate']) ? $this->response()['LastPerformanceDate'] : false; |
|
| 61 | 2 | if ($date) { |
|
| 62 | try { |
||
| 63 | 1 | return DateTime::createFromFormat(' Y-m-d\TG:i:sp', $date, $timezone); |
|
| 64 | } catch (Exception $e) { |
||
| 65 | trigger_error($e->getMessage(), E_USER_ERROR); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | 1 | return false; |
|
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @return Performance[] |
||
| 74 | */ |
||
| 75 | 1 | public function performances(): array |
|
| 78 | } |
||
| 79 | } |
||
| 80 |