|
1
|
|
|
<?php |
|
2
|
|
|
namespace Clubdeuce\Tessitura\Resources; |
|
3
|
|
|
|
|
4
|
|
|
use Clubdeuce\Tessitura\Base\Base; |
|
5
|
|
|
use DateTime; |
|
6
|
|
|
use DateTimeZone; |
|
7
|
|
|
|
|
8
|
|
|
class Season extends Base { |
|
9
|
|
|
|
|
10
|
2 |
|
public function getCreatedDateTime(string $timezone = 'America/New_York') : ?DateTime { |
|
11
|
|
|
|
|
12
|
|
|
// Check if 'CreatedDateTime' is present in the extra args |
|
13
|
2 |
|
if (!isset($this->extraArgs()['CreatedDateTime'])) { |
|
14
|
1 |
|
return null; // or throw an exception if required |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
try { |
|
18
|
1 |
|
$createdDateTime = new DateTime($this->extraArgs()['CreatedDateTime'], new DateTimeZone($timezone)); |
|
19
|
|
|
|
|
20
|
1 |
|
return $createdDateTime; |
|
21
|
|
|
} catch (\Exception $e) { |
|
22
|
|
|
trigger_error($e->getMessage(), E_USER_WARNING); |
|
23
|
|
|
return null; |
|
24
|
|
|
} |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
1 |
|
public function getDescription(): string |
|
28
|
|
|
{ |
|
29
|
1 |
|
return (string)$this->extraArgs()['Description']; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
2 |
|
public function getEndDateTime(string $timezone = 'America/New_York') : ?DateTime |
|
33
|
|
|
{ |
|
34
|
|
|
// Check if 'EndDateTime' is present in the extra args |
|
35
|
2 |
|
if (!isset($this->extraArgs()['EndDateTime'])) { |
|
36
|
1 |
|
return null; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
try { |
|
40
|
1 |
|
$endDateTime = new DateTime($this->extraArgs()['EndDateTime'], new DateTimeZone($timezone)); |
|
41
|
|
|
|
|
42
|
1 |
|
return $endDateTime; |
|
43
|
|
|
} catch (\Exception $e) { |
|
44
|
|
|
trigger_error($e->getMessage(), E_USER_WARNING); |
|
45
|
|
|
return null; |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
1 |
|
public function getId(): int |
|
50
|
|
|
{ |
|
51
|
1 |
|
return intval($this->extraArgs()['Id']); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
2 |
|
public function getStartDateTime(string $timezone = 'America/New_York') : ?\DateTime |
|
55
|
|
|
{ |
|
56
|
|
|
// Check if 'StartDateTime' is present in the extra args |
|
57
|
2 |
|
if (!isset($this->extraArgs()['StartDateTime'])) { |
|
58
|
1 |
|
return null; // or throw an exception if required |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
try { |
|
62
|
1 |
|
$startDateTime = new DateTime($this->extraArgs()['StartDateTime'], new DateTimeZone($timezone)); |
|
63
|
|
|
|
|
64
|
1 |
|
return $startDateTime; |
|
65
|
|
|
} catch (\Exception $e) { |
|
66
|
|
|
trigger_error($e->getMessage(), E_USER_WARNING); |
|
67
|
|
|
return null; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
} |