|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Clubdeuce\Tessitura\Resources; |
|
4
|
|
|
|
|
5
|
|
|
use Clubdeuce\Tessitura\Base\Base; |
|
6
|
|
|
use DateTime; |
|
7
|
|
|
use DateTimeZone; |
|
8
|
|
|
use Exception; |
|
9
|
|
|
|
|
10
|
|
|
class Performance extends Base |
|
11
|
|
|
{ |
|
12
|
|
|
protected DateTime $_date; |
|
13
|
|
|
|
|
14
|
1 |
|
public function title(): string |
|
15
|
|
|
{ |
|
16
|
1 |
|
return $this->extraArgs['PerformanceDescription'] ?? ''; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
1 |
|
public function productionSeasonId(): int |
|
20
|
|
|
{ |
|
21
|
1 |
|
return $this->extraArgs['ProductionSeason']['Id'] ?? 0; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
1 |
|
public function id(): int |
|
25
|
|
|
{ |
|
26
|
1 |
|
return intval($this->extraArgs['PerformanceId'] ?? 0); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
1 |
|
public function description(): string |
|
30
|
|
|
{ |
|
31
|
1 |
|
return (string)$this->extraArgs['PerformanceDescription']; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
3 |
|
public function doorsOpen(): ?DateTime |
|
35
|
|
|
{ |
|
36
|
3 |
|
if (!isset($this->extraArgs['DoorsOpen'])) { |
|
37
|
1 |
|
return null; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
try { |
|
41
|
2 |
|
return new DateTime($this->extraArgs['DoorsOpen']); |
|
42
|
1 |
|
} catch (Exception $e) { |
|
43
|
1 |
|
trigger_error($e->getMessage(), E_USER_NOTICE); |
|
44
|
|
|
|
|
45
|
1 |
|
return null; |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
4 |
|
public function facilityId(): int |
|
50
|
|
|
{ |
|
51
|
4 |
|
if (!isset($this->extraArgs['Facility'])) { |
|
52
|
1 |
|
return 0; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
3 |
|
if (!isset($this->extraArgs['Facility']['Id'])) { |
|
56
|
|
|
return 0; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
3 |
|
return intval($this->extraArgs['Facility']['Id']); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
3 |
|
public function facilityDescription(): string |
|
63
|
|
|
{ |
|
64
|
3 |
|
if (!isset($this->extraArgs['Facility'])) { |
|
65
|
|
|
return ''; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
3 |
|
if (!isset($this->extraArgs['Facility']['Description'])) { |
|
69
|
1 |
|
return ''; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
2 |
|
return $this->extraArgs['Facility']['Description']; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
4 |
|
public function startTime(): ?DateTime |
|
76
|
|
|
{ |
|
77
|
|
|
try { |
|
78
|
4 |
|
return $this->date(); |
|
79
|
1 |
|
} catch (Exception $e) { |
|
80
|
1 |
|
return null; |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @throws Exception |
|
86
|
|
|
*/ |
|
87
|
7 |
|
public function date(string $timezone = 'America/New_York'): ?DateTime |
|
88
|
|
|
{ |
|
89
|
7 |
|
if (isset($this->_date)) { |
|
90
|
1 |
|
return $this->_date; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
6 |
|
if (isset($this->extraArgs['PerformanceDate'])) { |
|
94
|
|
|
try { |
|
95
|
4 |
|
return new DateTime($this->extraArgs['PerformanceDate'], new DateTimeZone($timezone)); |
|
96
|
1 |
|
} catch (Exception $e) { |
|
97
|
1 |
|
throw new Exception( |
|
98
|
1 |
|
"Unable to convert performance date into DateTime object: {$e->getMessage()}", |
|
99
|
1 |
|
E_USER_WARNING |
|
100
|
1 |
|
); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
2 |
|
return null; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
1 |
|
public function statusId(): int |
|
108
|
|
|
{ |
|
109
|
1 |
|
return intval($this->extraArgs['PerformanceStatus']['Id']); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|