Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
MagnitudeRange
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
6 / 6
7
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
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
 min
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
 max
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
 average
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\Range;
3
4use Fdsn\Webservices\Event\Data\Magnitude;
5
6/**
7 * Data structure to handle magnitude range
8 *
9 * @param Magnitude $min    Min magnitude
10 * @param Magnitude $max    Max magnitude
11 *
12 * @return true, if every check is passed, false otherwise
13 */
14
15class MagnitudeRange {
16    private Magnitude $min;
17    private Magnitude $max;
18
19    function __construct( Magnitude $min, Magnitude $max) {
20        if( $min->value() <= $max->value() ){
21            $this->min = $min;
22            $this->max = $max;
23        }
24        else{
25            $this->min = $max;
26            $this->max = $min;
27        }
28    }
29
30    function __destruct(){ }
31
32    /**
33     * Returns magnitude range
34     *
35     * @return string [%s %.1f, %s%.1f] [min type value, max type value] format
36     */
37    function __toString(){ return sprintf("[%s, %s]", $this->min, $this->max); }
38
39    /**
40     * Get min magnitude obj
41     *
42     * @return Magnitude get min Magnitude obj
43     */
44    public function min():Magnitude { return $this->min; }
45
46    /**
47     * Get max magnitude obj
48     *
49     * @return Magnitude get max Magnitude obj
50     */
51    public function max():Magnitude { return $this->max; }
52
53    /**
54     * Get magnitude average obj
55     *
56     * @return Magnitude get average Magnitude obj
57     */
58    public function average():Magnitude { return new Magnitude( $this->min->type(), round( ( $this->min->value() + $this->max->value() ) / 2, 1) ); }
59} 

Paths

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

MagnitudeRange->__construct
19    function __construct( Magnitude $min, Magnitude $max) {
20        if( $min->value() <= $max->value() ){
 
20        if( $min->value() <= $max->value() ){
21            $this->min = $min;
 
28    }
19    function __construct( Magnitude $min, Magnitude $max) {
20        if( $min->value() <= $max->value() ){
 
25            $this->min = $max;
26            $this->max = $min;
27        }
28    }
 
28    }
MagnitudeRange->__destruct
30    function __destruct(){ }
MagnitudeRange->__toString
37    function __toString(){ return sprintf("[%s, %s]", $this->min, $this->max); }
MagnitudeRange->average
58    public function average():Magnitude { return new Magnitude( $this->min->type(), round( ( $this->min->value() + $this->max->value() ) / 2, 1) ); }
MagnitudeRange->max
51    public function max():Magnitude { return $this->max; }
MagnitudeRange->min
44    public function min():Magnitude { return $this->min; }