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
Event
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;
9use Fdsn\Webservices\Event\Data\Id;
10
11/**
12 * PHP library to access FDSN Webservices and request Event (earthquake) information in text format
13 * @see    https://www.fdsn.org/webservices/fdsnws-event-1.2.pdf FDSN official documentation
14 *
15 * @param string     $format     Accepted output kind format
16 * @param string     $user        Set your app name
17 * @param string     $fdns_server    Fdns webservice domain name (default: webservices.ms.ingv.it)
18 */
19class Event extends EventService{
20    /* Search by eventId */    
21    private Id $eventId;
22
23    protected EventData $event;
24
25    function __construct( string $format, ?string $user, string $fdns_server = Webservice::defaultFdsnServer, ?EventData $eventDataObj = null){
26        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
27
28        if( $eventDataObj instanceof EventData )
29            $this->event = $eventDataObj;
30
31        parent::__construct($format, $user, $fdns_server);
32    }
33    
34    /**
35     * Add filter based on ID Event (see https://terremoti.ingv.it/ to get event ids)
36     * @param Id    $eventId     Unique event ID
37     */
38    public function addFilterByEventId(Id $eventId):void { 
39        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
40
41        $this->eventId = $eventId; 
42        $this->parameters['eventid'] = sprintf("eventid=%s", $this->eventId);
43    }
44
45    /**
46     * Get event details , if only one event was found
47     * (filtering by eventId or when only one event is found by fetch() )
48     * @return \Fdsn\Webservices\Event\Data\Quake     Quake obj
49     */
50        public function details():EventData{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event; }
51
52    /**
53     * Get request event id 
54     * 
55     * @return \Fdsn\Webservices\Event\Data\Id Id obj
56     */
57        public function requestId():Id{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId; }
58
59    /**
60     * Check if event id is replaced (maybe an event is merged to another one)
61     * 
62     * @return bool    true if is replaced, false otherwise
63     */
64        public function isEventIdReplaced():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId->value() !== $this->event->eventId()->value(); }
65
66    /**
67     * Check if an earthquake is deleted (Shortcut for event type->isDeleted() )
68     * 
69     * @return bool    true if is deleted, false otherwise
70     */
71        public function isDeleted():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isDeleted(); }
72
73    /**
74     * Check if event type is earthquake (Shortcut for event type->isEarthquake() )
75     * 
76     * @return bool    true if is deleted, false otherwise
77     */
78        public function isEarthquake():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isEarthquake(); }
79}

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.

Event->__construct
25    function __construct( string $format, ?string $user, string $fdns_server = Webservice::defaultFdsnServer, ?EventData $eventDataObj = null){
26        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
 
26        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
27
28        if( $eventDataObj instanceof EventData )
 
28        if( $eventDataObj instanceof EventData )
 
29            $this->event = $eventDataObj;
30
31        parent::__construct($format, $user, $fdns_server);
 
31        parent::__construct($format, $user, $fdns_server);
32    }
25    function __construct( string $format, ?string $user, string $fdns_server = Webservice::defaultFdsnServer, ?EventData $eventDataObj = null){
26        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
 
26        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
27
28        if( $eventDataObj instanceof EventData )
 
28        if( $eventDataObj instanceof EventData )
 
31        parent::__construct($format, $user, $fdns_server);
32    }
25    function __construct( string $format, ?string $user, string $fdns_server = Webservice::defaultFdsnServer, ?EventData $eventDataObj = null){
26        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
 
28        if( $eventDataObj instanceof EventData )
 
29            $this->event = $eventDataObj;
30
31        parent::__construct($format, $user, $fdns_server);
 
31        parent::__construct($format, $user, $fdns_server);
32    }
25    function __construct( string $format, ?string $user, string $fdns_server = Webservice::defaultFdsnServer, ?EventData $eventDataObj = null){
26        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
 
28        if( $eventDataObj instanceof EventData )
 
31        parent::__construct($format, $user, $fdns_server);
32    }
Event->addFilterByEventId
38    public function addFilterByEventId(Id $eventId):void { 
39        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
 
39        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
40
41        $this->eventId = $eventId; 
 
41        $this->eventId = $eventId; 
42        $this->parameters['eventid'] = sprintf("eventid=%s", $this->eventId);
43    }
38    public function addFilterByEventId(Id $eventId):void { 
39        if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); 
 
41        $this->eventId = $eventId; 
42        $this->parameters['eventid'] = sprintf("eventid=%s", $this->eventId);
43    }
Event->details
50        public function details():EventData{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event; }
 
50        public function details():EventData{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event; }
 
50        public function details():EventData{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event; }
50        public function details():EventData{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event; }
 
50        public function details():EventData{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event; }
Event->isDeleted
71        public function isDeleted():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isDeleted(); }
 
71        public function isDeleted():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isDeleted(); }
 
71        public function isDeleted():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isDeleted(); }
71        public function isDeleted():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isDeleted(); }
 
71        public function isDeleted():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isDeleted(); }
Event->isEarthquake
78        public function isEarthquake():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isEarthquake(); }
 
78        public function isEarthquake():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isEarthquake(); }
 
78        public function isEarthquake():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isEarthquake(); }
78        public function isEarthquake():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isEarthquake(); }
 
78        public function isEarthquake():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->event->eventType()->isEarthquake(); }
Event->isEventIdReplaced
64        public function isEventIdReplaced():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId->value() !== $this->event->eventId()->value(); }
 
64        public function isEventIdReplaced():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId->value() !== $this->event->eventId()->value(); }
 
64        public function isEventIdReplaced():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId->value() !== $this->event->eventId()->value(); }
64        public function isEventIdReplaced():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId->value() !== $this->event->eventId()->value(); }
 
64        public function isEventIdReplaced():bool { if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId->value() !== $this->event->eventId()->value(); }
Event->requestId
57        public function requestId():Id{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId; }
 
57        public function requestId():Id{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId; }
 
57        public function requestId():Id{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId; }
57        public function requestId():Id{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId; }
 
57        public function requestId():Id{ if( self::debug ) printf("[%s] %d \n", __METHOD__, time()); return $this->eventId; }