GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Chart::getTo()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\LastFm\Model;
13
14
use Core23\LastFm\Exception\ApiException;
15
16
final class Chart
17
{
18
    /**
19
     * @var \DateTime
20
     */
21
    private $from;
22
23
    /**
24
     * @var \DateTime
25
     */
26
    private $to;
27
28
    public function __construct(\DateTime $from, \DateTime $to)
29
    {
30
        $this->from = $from;
31
        $this->to   = $to;
32
    }
33
34
    public function getFrom(): \DateTime
35
    {
36
        return $this->from;
37
    }
38
39
    public function getTo(): \DateTime
40
    {
41
        return $this->to;
42
    }
43
44
    /**
45
     * @throws ApiException
46
     *
47
     * @return Chart
48
     */
49
    public static function fromApi(array $data): self
50
    {
51
        $fromDate = \DateTime::createFromFormat('U', $data['from']);
52
53
        if (false === $fromDate) {
54
            throw new ApiException('Error fetching from date');
55
        }
56
57
        $toDate = \DateTime::createFromFormat('U', $data['to']);
58
59
        if (false === $toDate) {
60
            throw new ApiException('Error fetching to date');
61
        }
62
63
        return new self($fromDate, $toDate);
64
    }
65
}
66