Passed
Push — master ( 07ebfe...983cba )
by Smoren
02:11
created

src/Structs/Range.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Smoren\Sequence\Structs;
6
7
/**
8
 * @template T of int|float
9
 * @extends StepSequence<T>
10
 */
11
class Range extends StepSequence
12
{
13
    /**
14
     * @param T $start
15
     * @param int<0, max>|null $size
16
     * @param T $step
17
     */
18 49
    public function __construct($start, ?int $size, $step)
19
    {
20 49
        parent::__construct($start, $size, $step);
21
    }
22
23
    /**
24
     * @param int $index
25
     * @return T
26
     */
27 33
    public function getValueByIndex(int $index)
28
    {
29 33
        return $this->start + $index * $this->step;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->start + $index * $this->step returns the type integer which is incompatible with the documented return type Smoren\Sequence\Structs\T.
Loading history...
30
    }
31
32
    /**
33
     * @param T $previousValue
34
     * @return T
35
     */
36 22
    public function getNextValue($previousValue)
37
    {
38 22
        return $previousValue + $this->step;
39
    }
40
}
41