Passed
Pull Request — main (#15)
by
unknown
02:21
created

Season::getStartDateTime()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.2098

Importance

Changes 0
Metric Value
cc 3
eloc 7
c 0
b 0
f 0
nc 3
nop 1
dl 0
loc 13
ccs 5
cts 7
cp 0.7143
crap 3.2098
rs 10
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
            return null;
23
        }
24
    }
25
26 1
    public function getDescription(): string
27
    {
28 1
        return (string)$this->extraArgs()['Description'];
29
    }
30
31 2
    public function getEndDateTime(string $timezone = 'America/New_York') : ?DateTime
32
    {
33
        // Check if 'EndDateTime' is present in the extra args
34 2
        if (!isset($this->extraArgs()['EndDateTime'])) {
35 1
            return null;
36
        }
37
38
        try {
39 1
            $endDateTime = new DateTime($this->extraArgs()['EndDateTime'], new DateTimeZone($timezone));
40
41 1
            return $endDateTime;
42
        } catch (\Exception $e) {
43
            return null;
44
        }
45
    }
46
47 1
    public function getId(): int
48
    {
49 1
        return intval($this->extraArgs()['Id']);
50
    }
51
52 2
    public function getStartDateTime(string $timezone = 'America/New_York') : ?\DateTime
53
    {
54
        // Check if 'StartDateTime' is present in the extra args
55 2
        if (!isset($this->extraArgs()['StartDateTime'])) {
56 1
            return null; // or throw an exception if required
57
        }
58
59
        try {
60 1
            $startDateTime = new DateTime($this->extraArgs()['StartDateTime'], new DateTimeZone($timezone));
61
62 1
            return $startDateTime;
63
        } catch (\Exception $e) {
64
            return null;
65
        }
66
    }
67
}