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

Location::find()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

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 15
ccs 0
cts 12
cp 0
rs 9.4285
cc 1
eloc 9
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
    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