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.

Iso8601Entity::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * @package: chapi
4
 *
5
 * @author:  msiebeneicher
6
 * @since:   2015-09-25
7
 *
8
 * @link:    https://github.com/msiebeneicher/chapi/issues/36
9
 */
10
11
12
namespace Chapi\Entity\DatePeriod;
13
14
class Iso8601Entity
15
{
16
    const REG_EX_ISO_8601_STRING = '#(R[0-9]*)/(.*)/(P.*)#';
17
18
    /** @var string  */
19
    public $iso8601 = '';
20
21
    /** @var string  */
22
    public $repeat = '';
23
24
    /** @var string  */
25
    public $startTime = '';
26
27
    /** @var string  */
28
    public $interval = '';
29
30
    /**
31
     * @param string $iso8601
32
     */
33 9
    public function __construct($iso8601)
34
    {
35 9
        $this->iso8601 = $iso8601;
36
37 9
        $matches = $this->parseIsoString();
38 9
        if (count($matches) != 4) {
39 2
            throw new \InvalidArgumentException(sprintf("Can't parse '%s' as iso 8601 string.", $iso8601));
40
        }
41
42 7
        $this->repeat = $matches[1];
43 7
        $this->startTime = $matches[2];
44 7
        $this->interval = $matches[3];
45 7
    }
46
47
    /**
48
     * @return string[]
49
     */
50 9
    private function parseIsoString()
51
    {
52 9
        $matches = [];
53
54 9
        preg_match(self::REG_EX_ISO_8601_STRING, $this->iso8601, $matches);
55
56 9
        return $matches;
57
    }
58
}
59