Passed
Push — main ( 1e203e...21d5a8 )
by Daryl
03:03
created

Season::setStartDateTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Clubdeuce\Tessitura\Resources;
4
5
use Clubdeuce\Tessitura\Base\Base;
6
use Clubdeuce\Tessitura\Base\Resource;
7
use DateTime;
8
use DateTimeZone;
9
use Throwable;
10
11
class Season extends Resource
12
{
13 3
    public function getCreatedDateTime(string $timezone = 'America/New_York'): ?DateTime
14
    {
15 3
        if (!isset($this->extraArgs()['CreatedDateTime'])) {
16 2
            return null;
17
        }
18
19
        try {
20 2
            $createdDateTime = new DateTime($this->extraArgs()['CreatedDateTime'], new DateTimeZone($timezone));
21
22 1
            return $createdDateTime;
23 1
        } catch (Throwable $e) {
24 1
            return null;
25
        }
26
    }
27
28 1
    public function setCreatedDateTime(string $createdDateTime): void
29
    {
30 1
        $this->extraArgs['CreatedDateTime'] = $createdDateTime;
31
    }
32
33 1
    public function getDescription(): string
34
    {
35 1
        return (string)$this->extraArgs()['Description'];
36
    }
37
38
    public function setDescription(string $description): void
39
    {
40
        $this->extraArgs['Description'] = $description;
41
    }
42
43 2
    public function getEndDateTime(string $timezone = 'America/New_York'): ?DateTime
44
    {
45 2
        if (!isset($this->extraArgs()['EndDateTime'])) {
46 1
            return null;
47
        }
48
49
        try {
50 1
            $endDateTime = new DateTime($this->extraArgs()['EndDateTime'], new DateTimeZone($timezone));
51
52 1
            return $endDateTime;
53
        } catch (Throwable $e) {
54
            return null;
55
        }
56
    }
57
58 2
    public function getStartDateTime(string $timezone = 'America/New_York'): ?\DateTime
59
    {
60 2
        if (!isset($this->extraArgs()['StartDateTime'])) {
61 1
            return null;
62
        }
63
64
        try {
65 1
            $startDateTime = new DateTime($this->extraArgs()['StartDateTime'], new DateTimeZone($timezone));
66
67 1
            return $startDateTime;
68
        } catch (Throwable $e) {
69
            return null;
70
        }
71
    }
72
73 1
    public function setStartDateTime(string $startDateTime): void
74
    {
75 1
        $this->extraArgs['StartDateTime'] = $startDateTime;
76
    }
77
}
78