Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
9 / 9 |
|
100.00% |
7 / 7 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
Radius | |
100.00% |
7 / 7 |
|
100.00% |
9 / 9 |
|
100.00% |
7 / 7 |
|
100.00% |
5 / 5 |
7 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
__destruct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
__toString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
value | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isValid | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | namespace Fdsn\Webservices\Event\Structs; |
3 | |
4 | /** |
5 | * Data structure to handle Latitude,Longitude point |
6 | * |
7 | * @param float $radius Radius value (0 ~ 180) |
8 | */ |
9 | class Radius { |
10 | private float $value; |
11 | |
12 | private $validRadius = array('min' => 0, 'max' => 180); |
13 | |
14 | function __construct( float $value) { |
15 | |
16 | if( ! $this->isValid($value) ) |
17 | throw new \InvalidArgumentException("Radius invalid"); |
18 | |
19 | $this->value = $value; |
20 | } |
21 | |
22 | function __destruct(){ } |
23 | |
24 | function __toString(){ return sprintf("%.2f", $this->value); } |
25 | |
26 | /** |
27 | * Get radius value |
28 | * |
29 | * @return float radius |
30 | */ |
31 | public function value():float { return $this->value; } |
32 | |
33 | /** |
34 | * Check radius validity |
35 | * |
36 | * @return bool True if is valid, false otherwise |
37 | */ |
38 | private function isValid(float $value){ return ($this->validRadius['min'] <= $value && $value <= $this->validRadius['max']); } |
39 | } |