Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
91.67% covered (success)
91.67%
11 / 12
60.87% covered (warning)
60.87%
14 / 23
43.75% covered (danger)
43.75%
7 / 16
0.00% covered (danger)
0.00%
0 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
SingleInstance
91.67% covered (success)
91.67%
11 / 12
60.87% covered (warning)
60.87%
14 / 23
43.75% covered (danger)
43.75%
7 / 16
85.71% covered (warning)
85.71%
6 / 7
55.05
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
80.00% covered (warning)
80.00%
4 / 5
50.00% covered (danger)
50.00%
2 / 4
100.00% covered (success)
100.00%
1 / 1
4.12
 addFilterByEventId
100.00% covered (success)
100.00%
3 / 3
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
2.50
 details
100.00% covered (success)
100.00%
1 / 1
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
2.50
 requestId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 isEventIdReplaced
100.00% covered (success)
100.00%
1 / 1
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
2.50
 isDeleted
100.00% covered (success)
100.00%
1 / 1
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
2.50
 isEarthquake
100.00% covered (success)
100.00%
1 / 1
66.67% covered (warning)
66.67%
2 / 3
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
2.50
1<?php
2namespace Fdsn\Webservices\Event;
3
4use ArrayIterator;
5use IteratorAggregate;
6use Traversable;
7
8use Fdsn\Webservices\Webservice as Fdsnws_Webservice;
9use Fdsn\Webservices\Event\Event as Fdsnws_Webservice_Event;
10
11use Fdsn\Webservices\Event\Structs\Author as DS_Author;
12use Fdsn\Webservices\Event\Structs\Depth as DS_Depth;
13use Fdsn\Webservices\Event\Structs\Epicenter as DS_Epicenter;
14use Fdsn\Webservices\Event\Structs\Id as DS_Id;
15use Fdsn\Webservices\Event\Structs\LatLon as DS_LatLon;
16use Fdsn\Webservices\Event\Structs\Location as DS_Location;
17use Fdsn\Webservices\Event\Structs\Magnitude as DS_Magnitude;
18use Fdsn\Webservices\Event\Structs\Quake as DS_Quake;
19
20/**
21 * PHP library to access FDSN Webservices and request Event (earthquake) information in text format
22 * @see    https://www.fdsn.org/webservices/fdsnws-event-1.2.pdf FDSN official documentation
23 *
24 * @param string     $format     Accepted output kind format
25 * @param string     $user        Set your app name
26 * @param string     $fdns_server    Fdns webservice domain name (default: webservices.ms.ingv.it)
27 */
28class SingleInstance extends Fdsnws_Webservice_Event {
29    /* Search by eventId */    
30    private DS_Id $eventId;
31
32    protected DS_Quake $event;
33
34    function __construct( string $format, ?string $user, string $fdns_server = Fdsnws_Webservice::defaultFdsnServer, ?DS_Quake $dsQuakeObj = null){
35        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
36
37        if( $dsQuakeObj instanceof DS_Quake )
38            $this->event = $dsQuakeObj;
39
40        parent::__construct($format, $user, $fdns_server);
41    }
42    
43    /**
44     * Add filter based on ID Event (see https://terremoti.ingv.it/ to get event ids)
45     * @param Id    $eventId     Unique event ID
46     */
47    public function addFilterByEventId(DS_Id $eventId):void { 
48        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
49
50        $this->eventId = $eventId; 
51        $this->parameters['eventid'] = sprintf("eventid=%s", $this->eventId);
52    }
53
54    /**
55     * Get event details , if only one event was found
56     * (filtering by eventId or when only one event is found by fetch() )
57     * @return \Fdsn\Webservices\Event\Structs\Quake     Quake obj
58     */
59        public function details():DS_Quake{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event; }
60
61    /**
62     * Get request event id 
63     * 
64     * @return \Fdsn\Webservices\Event\Structs\Id Id obj
65     */
66        public function requestId():DS_Id{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId; }
67
68    /**
69     * Check if event id is replaced (maybe an event is merged to another one)
70     * 
71     * @return bool    true if is replaced, false otherwise
72     */
73        public function isEventIdReplaced():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId->value() !== $this->event->eventId()->value(); }
74
75    /**
76     * Check if an earthquake is deleted (Shortcut for event type->isDeleted() )
77     * 
78     * @return bool    true if is deleted, false otherwise
79     */
80        public function isDeleted():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isDeleted(); }
81
82    /**
83     * Check if event type is earthquake (Shortcut for event type->isEarthquake() )
84     * 
85     * @return bool    true if is deleted, false otherwise
86     */
87        public function isEarthquake():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isEarthquake(); }
88}

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.

SingleInstance->__construct
34    function __construct( string $format, ?string $user, string $fdns_server = Fdsnws_Webservice::defaultFdsnServer, ?DS_Quake $dsQuakeObj = null){
35        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
35        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
36
37        if( $dsQuakeObj instanceof DS_Quake )
37        if( $dsQuakeObj instanceof DS_Quake )
38            $this->event = $dsQuakeObj;
39
40        parent::__construct($format, $user, $fdns_server);
40        parent::__construct($format, $user, $fdns_server);
41    }
SingleInstance->addFilterByEventId
47    public function addFilterByEventId(DS_Id $eventId):void { 
48        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
48        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
49
50        $this->eventId = $eventId; 
50        $this->eventId = $eventId; 
51        $this->parameters['eventid'] = sprintf("eventid=%s", $this->eventId);
52    }
SingleInstance->details
59        public function details():DS_Quake{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event; }
59        public function details():DS_Quake{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event; }
59        public function details():DS_Quake{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event; }
SingleInstance->isDeleted
80        public function isDeleted():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isDeleted(); }
80        public function isDeleted():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isDeleted(); }
80        public function isDeleted():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isDeleted(); }
SingleInstance->isEarthquake
87        public function isEarthquake():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isEarthquake(); }
87        public function isEarthquake():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isEarthquake(); }
87        public function isEarthquake():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isEarthquake(); }
SingleInstance->isEventIdReplaced
73        public function isEventIdReplaced():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId->value() !== $this->event->eventId()->value(); }
73        public function isEventIdReplaced():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId->value() !== $this->event->eventId()->value(); }
73        public function isEventIdReplaced():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId->value() !== $this->event->eventId()->value(); }
SingleInstance->requestId
66        public function requestId():DS_Id{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId; }
66        public function requestId():DS_Id{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId; }
66        public function requestId():DS_Id{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId; }