Passed
Pull Request — dev (#91)
by Jordan
04:55
created

MutableFraction::setValue()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.4326

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 10
c 1
b 0
f 1
nc 4
nop 2
dl 0
loc 19
ccs 7
cts 11
cp 0.6364
crap 3.4326
rs 9.9332
1
<?php
2
3
namespace Samsara\Fermat\Values;
4
5
use Samsara\Fermat\Types\Fraction;
6
7
class MutableFraction extends Fraction
8
{
9
10 1
    protected function setValue(ImmutableDecimal $numerator, ImmutableDecimal $denominator): self
11
    {
12
13 1
        if ($numerator->isImaginary() xor $denominator->isImaginary()) {
14
            $this->imaginary = true;
15
        } else {
16 1
            $this->imaginary = false;
17
        }
18
19
        $this->value = [
20 1
            $numerator,
21 1
            $denominator
22
        ];
23
24 1
        if ($numerator->isNegative() xor $denominator->isNegative()) {
25
            $this->sign = true;
26
        }
27
28 1
        return $this;
29
30
    }
31
32
}