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