Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
Depth
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
6 / 6
8
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 __destruct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 value
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isValid
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 equals
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Fdsn\Webservices\Event\Structs;
3
4/**
5 * Data structure to handle Depth value
6 *
7 * @param float $value     depth
8 */
9class Depth {
10    private float $value;
11
12    private $validValues = array('min' => -100, 'max' => 10000); 
13
14    function __construct( float $value) {
15
16        if( ! $this->isValid($value) )
17            throw new \InvalidArgumentException("Depth value invalid");
18
19        $this->value = $value;
20    }
21
22    function __destruct(){ }
23
24    /**
25     * Get depth value
26     * @return string     Depth value in "%.2f km" format
27     */
28    function __toString(){ return sprintf("%.2f km", $this->value); }
29
30    /**
31     * Get depth value
32     * @return float    Depth value
33     */
34    public function value():float { return $this->value; }
35
36    /**
37     * Check if depth value is valid
38     * @return bool     True if is valid, false otherwise
39     */
40    private function isValid(float $value):bool { return ($this->validValues['min'] <= $value && $value <= $this->validValues['max']); }
41
42    /**
43     * Compare two objects
44     * @return bool        true are equals, false otherwise
45     */
46    public function equals(self $other):bool{ return $this->value == $other->value; }
47} 

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

Depth->__construct
14    function __construct( float $value) {
15
16        if( ! $this->isValid($value) )
17            throw new \InvalidArgumentException("Depth value invalid");
19        $this->value = $value;
20    }
Depth->__destruct
22    function __destruct(){ }
Depth->__toString
28    function __toString(){ return sprintf("%.2f km", $this->value); }
Depth->equals
46    public function equals(self $other):bool{ return $this->value == $other->value; }
Depth->isValid
40    private function isValid(float $value):bool { return ($this->validValues['min'] <= $value && $value <= $this->validValues['max']); }
40    private function isValid(float $value):bool { return ($this->validValues['min'] <= $value && $value <= $this->validValues['max']); }
40    private function isValid(float $value):bool { return ($this->validValues['min'] <= $value && $value <= $this->validValues['max']); }
Depth->value
34    public function value():float { return $this->value; }