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