Completed
Push — master ( 3718bf...59e23c )
by Pol
02:36
created

Location::getCoordinates()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace drupol\Yaroc\Examples;
4
5
/**
6
 * Class Location.
7
 *
8
 * @package drupol\Yaroc\Examples
9
 */
10
class Location extends BaseExample {
11
12
  /**
13
   * @var double[]
14
   */
15
  protected $coordinates;
16
17
  /**
18
   * Find random location.
19
   *
20
   * @return self
21
   */
22 1
  public function find() {
23 1
    $result = $this->randomOrgAPI->call('generateDecimalFractions', ['n' => 3, 'decimalPlaces' => 10])
24 1
      ->getData();
25
26 1
    $this->coordinates = [
0 ignored issues
show
Documentation Bug introduced by Pol Dellaiera
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...
27 1
      'x' => rad2deg($result[0] * 2 * pi() - pi()),
28 1
      'y' => rad2deg(pi()/2 - acos($result[1] * 2 - 1)),
29 1
      'z' => $result[2] * 1000,
30
    ];
31
32 1
    return $this;
33
  }
34
35
  /**
36
   * Get the coordinates.
37
   *
38
   * @return string
0 ignored issues
show
Documentation introduced by Pol Dellaiera
Should the return type not be double[]?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
39
   */
40 1
  public function getCoordinates() {
41 1
    return $this->coordinates;
42
  }
43
44
}
45