Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
91.67% |
11 / 12 |
|
60.87% |
14 / 23 |
|
43.75% |
7 / 16 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| SingleInstance | |
91.67% |
11 / 12 |
|
60.87% |
14 / 23 |
|
43.75% |
7 / 16 |
|
85.71% |
6 / 7 |
55.05 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
4 / 4 |
|
80.00% |
4 / 5 |
|
50.00% |
2 / 4 |
|
100.00% |
1 / 1 |
4.12 | |||
| addFilterByEventId | |
100.00% |
3 / 3 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
| details | |
100.00% |
1 / 1 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
| requestId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| isEventIdReplaced | |
100.00% |
1 / 1 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
| isDeleted | |
100.00% |
1 / 1 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
| isEarthquake | |
100.00% |
1 / 1 |
|
66.67% |
2 / 3 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
| 1 | <?php |
| 2 | namespace Fdsn\Webservices\Event; |
| 3 | |
| 4 | use ArrayIterator; |
| 5 | use IteratorAggregate; |
| 6 | use Traversable; |
| 7 | |
| 8 | use Fdsn\Webservices\Webservice as Fdsnws_Webservice; |
| 9 | use Fdsn\Webservices\Event\Event as Fdsnws_Webservice_Event; |
| 10 | |
| 11 | use Fdsn\Webservices\Event\Structs\Author as DS_Author; |
| 12 | use Fdsn\Webservices\Event\Structs\Depth as DS_Depth; |
| 13 | use Fdsn\Webservices\Event\Structs\Epicenter as DS_Epicenter; |
| 14 | use Fdsn\Webservices\Event\Structs\Id as DS_Id; |
| 15 | use Fdsn\Webservices\Event\Structs\LatLon as DS_LatLon; |
| 16 | use Fdsn\Webservices\Event\Structs\Location as DS_Location; |
| 17 | use Fdsn\Webservices\Event\Structs\Magnitude as DS_Magnitude; |
| 18 | use 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 | */ |
| 28 | class 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 | } |