Passed
Push — dev ( 3795a8...3f4d81 )
by Jordan
14:20
created

MutableNumber::isComplex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Samsara\Fermat\Values;
4
5
use Samsara\Fermat\Types\Number;
6
use Samsara\Fermat\Types\Base\DecimalInterface;
7
use Samsara\Fermat\Types\Base\NumberInterface;
8
use Samsara\Fermat\Numbers;
9
10
class MutableNumber extends Number implements NumberInterface, DecimalInterface
11
{
12
13 1
    public function modulo($mod)
14
    {
15 1
        $oldBase = $this->convertForModification();
16
17 1
        return (new MutableNumber(bcmod($this->getValue(), $mod), $this->getPrecision()))->convertFromModification($oldBase);
18
    }
19
20 1
    public function continuousModulo($mod)
21
    {
22
23 1
        $mod = Numbers::makeOrDont(Numbers::IMMUTABLE, $mod, $this->precision+1);
24 1
        $oldNum = Numbers::make(Numbers::IMMUTABLE, $this->getValue(), $this->precision+1);
25
26 1
        $multiple = $oldNum->divide($mod)->floor();
0 ignored issues
show
Bug introduced by
The method floor() does not exist on Samsara\Fermat\Types\Base\NumberInterface. It seems like you code against a sub-type of Samsara\Fermat\Types\Base\NumberInterface such as Samsara\Fermat\Values\ImmutableNumber or Samsara\Fermat\Values\MutableNumber. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $multiple = $oldNum->divide($mod)->/** @scrutinizer ignore-call */ floor();
Loading history...
Bug introduced by
The method floor() does not exist on Samsara\Fermat\Types\Base\FractionInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $multiple = $oldNum->divide($mod)->/** @scrutinizer ignore-call */ floor();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method divide() does not exist on Samsara\Fermat\Types\Base\FractionInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Samsara\Fermat\Types\Base\FractionInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $multiple = $oldNum->/** @scrutinizer ignore-call */ divide($mod)->floor();
Loading history...
Bug introduced by
The method divide() does not exist on Samsara\Fermat\Types\Base\CoordinateInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $multiple = $oldNum->/** @scrutinizer ignore-call */ divide($mod)->floor();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method divide() does not exist on Samsara\Fermat\Values\CartesianCoordinate. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $multiple = $oldNum->/** @scrutinizer ignore-call */ divide($mod)->floor();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
28 1
        $remainder = $oldNum->subtract($mod->multiply($multiple));
0 ignored issues
show
Bug introduced by
The method subtract() does not exist on Samsara\Fermat\Types\Base\FractionInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Samsara\Fermat\Types\Base\FractionInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        /** @scrutinizer ignore-call */ $remainder = $oldNum->subtract($mod->multiply($multiple));
Loading history...
Bug introduced by
The method subtract() does not exist on Samsara\Fermat\Values\CartesianCoordinate. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        /** @scrutinizer ignore-call */ $remainder = $oldNum->subtract($mod->multiply($multiple));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method subtract() does not exist on Samsara\Fermat\Types\Base\CoordinateInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        /** @scrutinizer ignore-call */ $remainder = $oldNum->subtract($mod->multiply($multiple));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
30 1
        return Numbers::make(Numbers::MUTABLE, $remainder->truncate($this->precision)->getValue());
0 ignored issues
show
Bug introduced by
The method truncate() does not exist on Samsara\Fermat\Types\Base\FractionInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        return Numbers::make(Numbers::MUTABLE, $remainder->/** @scrutinizer ignore-call */ truncate($this->precision)->getValue());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method truncate() does not exist on Samsara\Fermat\Types\Base\NumberInterface. It seems like you code against a sub-type of Samsara\Fermat\Types\Base\NumberInterface such as Samsara\Fermat\Values\ImmutableNumber or Samsara\Fermat\Values\MutableNumber. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        return Numbers::make(Numbers::MUTABLE, $remainder->/** @scrutinizer ignore-call */ truncate($this->precision)->getValue());
Loading history...
Bug introduced by
The method getValue() does not exist on Samsara\Fermat\Types\Base\DecimalInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Samsara\Fermat\Types\Base\DecimalInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        return Numbers::make(Numbers::MUTABLE, $remainder->truncate($this->precision)->/** @scrutinizer ignore-call */ getValue());
Loading history...
31
32
    }
33
34
    /**
35
     * @param $value
36
     *
37
     * @return MutableNumber
38
     */
39 2
    protected function setValue($value)
40
    {
41 2
        $this->value = $value;
42
43 2
        return $this;
44
    }
45
46
    /**
47
     * @return bool
48
     */
49
    public function isComplex(): bool
50
    {
51
        return false;
52
    }
53
54
}