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

MutableFraction   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 63.64%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 22
ccs 7
cts 11
cp 0.6364
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 19 3
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
}