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.
Completed
Push — master ( 51e265...c47369 )
by Nicholas
03:12
created

Range   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 10
c 2
b 0
f 1
lcom 1
cbo 3
dl 0
loc 98
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A between() 0 4 1
A betweenEncodedCharacters() 0 7 1
A getStart() 0 4 1
A getEnd() 0 4 1
A representsSingleCodepoint() 0 4 1
A expand() 0 6 1
A yieldCodepoints() 0 9 2
1
<?php
2
3
namespace UCD\Unicode\Codepoint;
4
5
use UCD\Unicode\Codepoint;
6
use UCD\Exception\InvalidRangeException;
7
use UCD\Unicode\TransformationFormat;
8
9
class Range
10
{
11
    /**
12
     * @var Codepoint
13
     */
14
    private $start;
15
16
    /**
17
     * @var Codepoint
18
     */
19
    private $end;
20
21
    /**
22
     * @param Codepoint $start
23
     * @param Codepoint $end
24
     * @throws InvalidRangeException
25
     */
26
    protected function __construct(Codepoint $start, Codepoint $end)
27
    {
28
        if ($start->getValue() > $end->getValue()) {
29
            throw new InvalidRangeException();
30
        }
31
32
        $this->start = $start;
33
        $this->end = $end;
34
    }
35
36
    /**
37
     * @param Codepoint $start
38
     * @param Codepoint $end
39
     * @return self
40
     */
41
    public static function between(Codepoint $start, Codepoint $end)
42
    {
43
        return new self($start, $end);
44
    }
45
46
    /**
47
     * @param string $start
48
     * @param string $end
49
     * @param TransformationFormat $encoding
50
     * @return self
51
     */
52
    public static function betweenEncodedCharacters($start, $end, TransformationFormat $encoding)
53
    {
54
        return self::between(
55
            Codepoint::fromEncodedCharacter($start, $encoding),
56
            Codepoint::fromEncodedCharacter($end, $encoding)
57
        );
58
    }
59
60
    /**
61
     * @return Codepoint
62
     */
63
    public function getStart()
64
    {
65
        return $this->start;
66
    }
67
68
    /**
69
     * @return Codepoint
70
     */
71
    public function getEnd()
72
    {
73
        return $this->end;
74
    }
75
76
    /**
77
     * @return bool
78
     */
79
    public function representsSingleCodepoint()
80
    {
81
        return $this->start->equals($this->end);
82
    }
83
84
    /**
85
     * @return Codepoint[]|Collection
86
     */
87
    public function expand()
88
    {
89
        return new Collection(
90
            $this->yieldCodepoints()
91
        );
92
    }
93
94
    /**
95
     * @return \Generator
96
     */
97
    private function yieldCodepoints()
98
    {
99
        $start = $this->getStart()->getValue();
100
        $end = $this->getEnd()->getValue();
101
102
        for ($i = $start; $i <= $end; $i++) {
103
            yield Codepoint::fromInt($i);
104
        }
105
    }
106
}