Test Failed
Push — dev ( 3254b4...32905a )
by Jordan
13:46
created

MutableDecimal   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A modulo() 0 5 1
A setValue() 0 5 1
A isComplex() 0 3 1
A continuousModulo() 0 11 1
1
<?php
2
3
namespace Samsara\Fermat\Values;
4
5
use Samsara\Fermat\Types\Decimal;
6
use Samsara\Fermat\Numbers;
7
8
class MutableDecimal extends Decimal
9
{
10
11
    public function modulo($mod)
12
    {
13
        $oldBase = $this->convertForModification();
14
15
        return (new MutableDecimal(bcmod($this->getValue(), $mod), $this->getPrecision()))->convertFromModification($oldBase);
16
    }
17
18
    public function continuousModulo($mod)
19
    {
20
21
        $mod = Numbers::makeOrDont(Numbers::IMMUTABLE, $mod, $this->precision+1);
22
        $oldNum = Numbers::make(Numbers::IMMUTABLE, $this->getValue(), $this->precision+1);
23
24
        $multiple = $oldNum->divide($mod)->floor();
0 ignored issues
show
Bug introduced by
The method divide() does not exist on Samsara\Fermat\Types\Bas...faces\FractionInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Samsara\Fermat\Types\Bas...faces\FractionInterface. ( Ignorable by Annotation )

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

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

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

24
        $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\Bas...ces\CoordinateInterface. ( Ignorable by Annotation )

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

24
        $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

24
        $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 floor() does not exist on Samsara\Fermat\Types\Bas...erfaces\NumberInterface. It seems like you code against a sub-type of Samsara\Fermat\Types\Bas...erfaces\NumberInterface such as Samsara\Fermat\Types\ComplexNumber or Samsara\Fermat\Types\Decimal. ( Ignorable by Annotation )

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

24
        $multiple = $oldNum->divide($mod)->/** @scrutinizer ignore-call */ floor();
Loading history...
25
26
        $remainder = $oldNum->subtract($mod->multiply($multiple));
0 ignored issues
show
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

26
        /** @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\Bas...faces\FractionInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Samsara\Fermat\Types\Bas...faces\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
        /** @scrutinizer ignore-call */ $remainder = $oldNum->subtract($mod->multiply($multiple));
Loading history...
Bug introduced by
The method subtract() does not exist on Samsara\Fermat\Types\Bas...ces\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
        /** @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...
27
28
        return Numbers::make(Numbers::MUTABLE, $remainder->truncate($this->precision)->getValue());
0 ignored issues
show
Bug introduced by
The method getValue() does not exist on Samsara\Fermat\Types\Bas...rfaces\DecimalInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Samsara\Fermat\Types\Bas...rfaces\DecimalInterface. ( Ignorable by Annotation )

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

28
        return Numbers::make(Numbers::MUTABLE, $remainder->truncate($this->precision)->/** @scrutinizer ignore-call */ getValue());
Loading history...
Bug introduced by
The method truncate() does not exist on Samsara\Fermat\Types\Bas...faces\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
        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\Bas...erfaces\NumberInterface. It seems like you code against a sub-type of Samsara\Fermat\Types\Bas...erfaces\NumberInterface such as Samsara\Fermat\Types\ComplexNumber or Samsara\Fermat\Types\Decimal. ( Ignorable by Annotation )

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

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