Completed
Push — master ( d62f94...2c3725 )
by Jordan
15s queued 13s
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
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0
eloc 8
wmc 1
1
<?php
2
3
namespace Samsara\Fermat\Complex\Values;
4
5
use Samsara\Fermat\Core\Types\Base\Interfaces\Numbers\SimpleNumberInterface;
6
use Samsara\Fermat\Complex\Types\ComplexNumber;
7
use Samsara\Fermat\Coordinates\Values\CartesianCoordinate;
8
use Samsara\Fermat\Core\Values\ImmutableDecimal;
9
use Samsara\Fermat\Core\Values\ImmutableFraction;
10
11
class MutableComplexNumber extends ComplexNumber
12
{
13
14 82
    protected function setValue(
15
        ImmutableDecimal|ImmutableFraction $realPart,
16
        ImmutableDecimal|ImmutableFraction $imaginaryPart,
17
        ?int $scale = null
18
    ): static|MutableComplexNumber
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected '|', expecting '{' or ';' on line 18 at column 13
Loading history...
19
    {
20 82
        $scale = $scale ?? $this->getScale();
21
22 82
        $this->scale = $scale;
23 82
        $this->realPart = $realPart;
24 82
        $this->imaginaryPart = $imaginaryPart;
25
26 82
        $this->cachedCartesian = new CartesianCoordinate($realPart, $imaginaryPart);
27
28 82
        $polar = $this->cachedCartesian->asPolar();
29
30 82
        $this->cachedPolar = $polar;
31
32 82
        return $this;
33
    }
34
35
}