Total Complexity | 4 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Coverage | 80% |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
14 | abstract class IntSequence implements SequenceInterface |
||
15 | { |
||
16 | use SequenceTrait; |
||
17 | |||
18 | /** |
||
19 | * @var int |
||
20 | */ |
||
21 | protected int $start; |
||
22 | /** |
||
23 | * @var int<0, max>|null |
||
24 | */ |
||
25 | protected ?int $size; |
||
26 | /** |
||
27 | * @var int |
||
28 | */ |
||
29 | protected int $step; |
||
30 | |||
31 | /** |
||
32 | * @param int $start |
||
33 | * @param int<0, max>|null $size |
||
34 | * @param int $step |
||
35 | */ |
||
36 | 10 | public function __construct(int $start, ?int $size, int $step = 1) |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * @param int $index |
||
45 | * @return int |
||
46 | */ |
||
47 | abstract public function getValueByIndex(int $index): int; |
||
48 | |||
49 | /** |
||
50 | * @return int |
||
51 | */ |
||
52 | public function getStartValue(): int |
||
53 | { |
||
54 | return $this->getValueByIndex(0); |
||
|
|||
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritDoc} |
||
59 | * @return int |
||
60 | */ |
||
61 | 10 | public function offsetGet($offset): int |
|
62 | { |
||
63 | 10 | return (int)$this->_offsetGet($offset); |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * {@inheritDoc} |
||
68 | */ |
||
69 | 7 | public function getIterator(): IntSequenceIterator |
|
72 | } |
||
73 | } |
||
74 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: