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

Location::getCoordinates()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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