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