Failed Conditions
Pull Request — dev (#50)
by Jordan
09:06 queued 04:26
created

TrigonometryProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 2
Metric Value
eloc 7
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10
c 4
b 1
f 2
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A degreesToRadians() 0 6 1
A radiansToDegrees() 0 6 1
1
<?php
2
3
namespace Samsara\Fermat\Provider;
4
5
use Samsara\Exceptions\UsageError\IntegrityConstraint;
6
use Samsara\Fermat\Numbers;
7
8
class TrigonometryProvider
9
{
10
11
    /**
12
     * @param $radians
13
     *
14
     * @return string
15
     * @throws IntegrityConstraint
16
     */
17 1
    public static function radiansToDegrees($radians)
18
    {
19 1
        $radians = Numbers::makeOrDont(Numbers::IMMUTABLE, $radians);
20 1
        $pi = Numbers::makePi($radians->getPrecision() + 2);
21
        
22 1
        return $radians->multiply(180)->divide($pi)->round($radians->getPrecision()-2)->getValue();
0 ignored issues
show
Bug introduced by
The method round() does not exist on Samsara\Fermat\Types\Bas...mbers\FractionInterface. ( Ignorable by Annotation )

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

22
        return $radians->multiply(180)->divide($pi)->/** @scrutinizer ignore-call */ round($radians->getPrecision()-2)->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 round() does not exist on Samsara\Fermat\Types\Bas...Numbers\NumberInterface. It seems like you code against a sub-type of Samsara\Fermat\Types\Bas...Numbers\NumberInterface such as Samsara\Fermat\Types\Bas...umbers\DecimalInterface 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

22
        return $radians->multiply(180)->divide($pi)->/** @scrutinizer ignore-call */ round($radians->getPrecision()-2)->getValue();
Loading history...
Bug introduced by
The method getValue() does not exist on Samsara\Fermat\Types\Bas...Numbers\NumberInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Samsara\Fermat\Types\Bas...Numbers\NumberInterface. ( Ignorable by Annotation )

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

22
        return $radians->multiply(180)->divide($pi)->round($radians->getPrecision()-2)->/** @scrutinizer ignore-call */ getValue();
Loading history...
23
    }
24
25
    /**
26
     * @param $degrees
27
     *
28
     * @return string
29
     * @throws IntegrityConstraint
30
     */
31 1
    public static function degreesToRadians($degrees)
32
    {
33 1
        $degrees = Numbers::makeOrDont(Numbers::IMMUTABLE, $degrees);
34 1
        $pi = Numbers::makePi($degrees->getPrecision() + 1);
35
36 1
        return $degrees->multiply($pi)->divide(180)->round($degrees->getPrecision())->getValue();
37
    }
38
39
}