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

IntExponential   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 3
c 1
b 0
f 0
dl 0
loc 17
ccs 2
cts 4
cp 0.5
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getValueByIndex() 0 3 1
A getStartValue() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Smoren\Sequence\Structs;
6
7
/**
8
 * {@inheritDoc}
9
 */
10
class IntExponential extends IntSequence
11
{
12
    /**
13
     * @param int $index
14
     * @return int
15
     */
16 3
    public function getValueByIndex(int $index): int
17
    {
18 3
        return (int)($this->start * ($this->step ** $index));
19
    }
20
21
    /**
22
     * @return int
23
     */
24
    public function getStartValue(): int
25
    {
26
        return $this->getValueByIndex(0);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getValueByIndex(0) returns the type integer 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...
27
    }
28
}
29