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

Location   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
cbo 2
dl 0
loc 35
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 0 12 1
A getCoordinates() 0 3 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
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
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