Completed
Pull Request — master (#2)
by Pol
07:20 queued 05:24
created

Location   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
cbo 4
dl 0
loc 40
ccs 0
cts 16
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 0 15 1
A getCoordinates() 0 4 1
1
<?php
2
3
namespace drupol\Yaroc\Examples;
4
5
use drupol\Yaroc\Plugin\Provider;
6
7
/**
8
 * Class Location.
9
 */
10
class Location extends BaseExample
11
{
12
    /**
13
     * @var double[]
14
     */
15
    protected $coordinates;
16
17
    /**
18
     * @throws \Http\Client\Exception
19
     *
20
     * @return $this
21
     *
22
     * @SuppressWarnings(PHPMD.StaticAccess)
23
     */
24
    public function find()
25
    {
26
        $provider = Provider::withResource('generateDecimalFractions')
27
            ->withParameters(['n' => 3, 'decimalPlaces' => 10]);
28
29
        $result = $this->getRandomOrgAPI()->getData($provider);
30
31
        $this->coordinates = [
0 ignored issues
show
Documentation Bug introduced by
It seems like array('x' => rad2deg($re...' => $result[2] * 1000) of type array<string,double|inte...,"z":"integer|double"}> is incompatible with the declared type array<integer,double> of property $coordinates.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
32
            'x' => rad2deg($result[0] * 2 * pi() - pi()),
33
            'y' => rad2deg(pi()/2 - acos($result[1] * 2 - 1)),
34
            'z' => $result[2] * 1000,
35
        ];
36
37
        return $this;
38
    }
39
40
    /**
41
     * Get the coordinates.
42
     *
43
     * @return double[]
44
     */
45
    public function getCoordinates()
46
    {
47
        return $this->coordinates;
48
    }
49
}
50