Completed
Pull Request — master (#2)
by Pol
02:04
created

Location   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
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 38
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
    public function find()
23
    {
24
        $provider = Provider::withResource('generateDecimalFractions')
25
            ->withParameters(['n' => 3, 'decimalPlaces' => 10]);
26
27
        $result = $this->getRandomOrgAPI()->getData($provider);
28
29
        $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...
30
            'x' => rad2deg($result[0] * 2 * pi() - pi()),
31
            'y' => rad2deg(pi()/2 - acos($result[1] * 2 - 1)),
32
            'z' => $result[2] * 1000,
33
        ];
34
35
        return $this;
36
    }
37
38
    /**
39
     * Get the coordinates.
40
     *
41
     * @return double[]
42
     */
43
    public function getCoordinates()
44
    {
45
        return $this->coordinates;
46
    }
47
}
48