Passed
Push — master ( ae6524...8dfa4a )
by Smoren
02:10
created

FloatExponential::getStartValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Smoren\Sequence\Structs;
6
7
use Smoren\Sequence\Traits\SequenceTrait;
8
9
/**
10
 * {@inheritDoc}
11
 */
12
class FloatExponential extends FloatSequence
13
{
14
    use SequenceTrait;
15
16
    /**
17
     * @param int $index
18
     * @return float
19
     */
20 3
    public function getValueByIndex(int $index): float
21
    {
22 3
        return $this->start * ($this->step ** $index);
23
    }
24
25
    /**
26
     * @return float
27
     */
28
    public function getStartValue(): float
29
    {
30
        return $this->getValueByIndex(0);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueByIndex(0) returns the type double which is incompatible with the return type mandated by Smoren\Sequence\Interfac...erface::getStartValue() of Smoren\Sequence\Interfaces\T.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
31
    }
32
}
33