Passed
Pull Request — dev (#50)
by Jordan
08:27
created

MutableComplexNumber   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 13 1
1
<?php
2
3
namespace Samsara\Fermat\Values;
4
5
use Samsara\Fermat\Types\Base\Interfaces\Numbers\SimpleNumberInterface;
6
use Samsara\Fermat\Types\ComplexNumber;
7
use Samsara\Fermat\Values\Geometry\CoordinateSystems\CartesianCoordinate;
8
9
class MutableComplexNumber extends ComplexNumber
10
{
11
12 1
    protected function setValue(SimpleNumberInterface $realPart, SimpleNumberInterface $imaginaryPart)
13
    {
14 1
        $this->realPart = $realPart;
0 ignored issues
show
Documentation Bug introduced by
$realPart is of type Samsara\Fermat\Types\Bas...s\SimpleNumberInterface, but the property $realPart was declared to be of type Samsara\Fermat\Values\Im...alues\ImmutableFraction. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
15 1
        $this->imaginaryPart = $imaginaryPart;
0 ignored issues
show
Documentation Bug introduced by
$imaginaryPart is of type Samsara\Fermat\Types\Bas...s\SimpleNumberInterface, but the property $imaginaryPart was declared to be of type Samsara\Fermat\Values\Im...alues\ImmutableFraction. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
16
17 1
        $this->cachedCartesian = new CartesianCoordinate($realPart, $imaginaryPart);
18
19 1
        $polar = $this->cachedCartesian->asPolar();
20
21 1
        $this->values->set(0, $polar->getDistanceFromOrigin());
22 1
        $this->values->set(1, $polar->getPolarAngle());
23
24 1
        return $this;
25
    }
26
27
}