Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
8 / 8 |
|
85.71% |
6 / 7 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
| Epicenter | |
100.00% |
9 / 9 |
|
100.00% |
8 / 8 |
|
85.71% |
6 / 7 |
|
100.00% |
6 / 6 |
7.14 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __destruct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __toString | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| point | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| depth | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| equals | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
| 1 | <?php |
| 2 | namespace Fdsn\Webservices\Event\Structs; |
| 3 | |
| 4 | //use Fdsn\Webservices\Event\Structs\LatLon; |
| 5 | //use Fdsn\Webservices\Event\Structs\Depth; |
| 6 | |
| 7 | /** |
| 8 | * Data structure to handle epicenters |
| 9 | * |
| 10 | * @param LatLon $point LatLon obj |
| 11 | * @param Depth $depth Depth obj |
| 12 | * |
| 13 | * @return true, if every check is passed, false otherwise |
| 14 | */ |
| 15 | class Epicenter { |
| 16 | private LatLon $point; |
| 17 | private Depth $depth; |
| 18 | |
| 19 | function __construct( LatLon $point, Depth $depth) { |
| 20 | $this->point = $point; |
| 21 | $this->depth = $depth; |
| 22 | } |
| 23 | |
| 24 | function __destruct(){ } |
| 25 | |
| 26 | /** |
| 27 | * Returns epicenter in lat, lon, depth readable format |
| 28 | * |
| 29 | * @return string lat, lon, depth ("%.5f,%.5f, %.2f km") |
| 30 | */ |
| 31 | function __toString(){ |
| 32 | return sprintf("%s, %s", |
| 33 | $this->point, |
| 34 | $this->depth); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Get epicenter coordinates |
| 39 | * |
| 40 | * @return LatLon epicenter coordinates |
| 41 | */ |
| 42 | public function point():LatLon { return $this->point; } |
| 43 | |
| 44 | /** |
| 45 | * Get epicenter depth |
| 46 | * |
| 47 | * @return Depth epicenter depth |
| 48 | */ |
| 49 | public function depth():Depth { return $this->depth; } |
| 50 | |
| 51 | /** |
| 52 | * Compare two objects |
| 53 | * @return bool true are equals, false otherwise |
| 54 | */ |
| 55 | public function equals(self $other):bool{ return $this->point == $other->point && $this->depth == $other->depth; } |
| 56 | } |