Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
25 / 25 |
|
100.00% |
12 / 12 |
|
100.00% |
12 / 12 |
|
100.00% |
12 / 12 |
CRAP | |
100.00% |
1 / 1 |
| Quake | |
100.00% |
25 / 25 |
|
100.00% |
12 / 12 |
|
100.00% |
12 / 12 |
|
100.00% |
12 / 12 |
12 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __destruct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __toString | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| eventId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| originTimeObj | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| originTimeUTC | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| originTimeUTCISO8601 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| magnitude | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| epicenter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| location | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| author | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| eventType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Fdsn\Webservices\Event\Structs; |
| 3 | |
| 4 | //use Fdsn\Webservices\Event\Structs\Magnitude; |
| 5 | //use Fdsn\Webservices\Event\Structs\Epicenter; |
| 6 | //use Fdsn\Webservices\Event\Structs\Location; |
| 7 | //use Fdsn\Webservices\Event\Structs\Author; |
| 8 | |
| 9 | /** |
| 10 | * Data structure to handle information about earthquakes |
| 11 | * This object must be instantiated only with quake data |
| 12 | * |
| 13 | * @param Id $eventId EventID according to INGV ONT ID (see https://terremoti.ingv.it/) |
| 14 | * @param \DateTime|null $originTimeUTC Quake UTC origin time, in ISO 8601 format (see: date('c')) |
| 15 | * @param Location|null $location Where the quake origin is |
| 16 | * @param Magnitude|null $magnitude Magnitude obj |
| 17 | * @param Epicenter|null $epicenter Epicenter obj |
| 18 | * @param Author|null $author Author obj |
| 19 | * @param EventType|null $eventType EventType obj |
| 20 | */ |
| 21 | class Quake { |
| 22 | private Id $eventId; |
| 23 | private \DateTime $originTimeUTC; |
| 24 | private Location $location; |
| 25 | private Magnitude $magnitude; |
| 26 | private Epicenter $epicenter; |
| 27 | private Author $author; |
| 28 | private EventType $eventType; |
| 29 | |
| 30 | function __construct( |
| 31 | Id $eventId, |
| 32 | \DateTime $originTimeUTC, |
| 33 | Location $location, |
| 34 | Magnitude $magnitude, |
| 35 | Epicenter $epicenter, |
| 36 | ?Author $author = null, |
| 37 | ?EventType $eventType = null) { |
| 38 | |
| 39 | $this->eventId = $eventId; |
| 40 | $this->originTimeUTC = $originTimeUTC; |
| 41 | $this->location = $location; |
| 42 | $this->magnitude = $magnitude; |
| 43 | $this->epicenter = $epicenter; |
| 44 | $this->author = $author; |
| 45 | $this->eventType = $eventType; |
| 46 | } |
| 47 | |
| 48 | function __destruct(){ } |
| 49 | |
| 50 | /** |
| 51 | * Returns quake details |
| 52 | * |
| 53 | * @return string Quake details: eventId, originTimeUTC, magnitude, epicenter, location |
| 54 | */ |
| 55 | function __toString(){ |
| 56 | return sprintf("Quake ID %s, on %s, mag: %s, origin: %s, location: %s, type: %s)", |
| 57 | $this->eventId, //it's already converted to int in Id::__toString() |
| 58 | $this->originTimeUTC(), |
| 59 | $this->magnitude, |
| 60 | $this->epicenter, |
| 61 | $this->location, |
| 62 | $this->eventType |
| 63 | ); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Get event ID |
| 68 | * |
| 69 | * @return int Event ID |
| 70 | */ |
| 71 | public function eventId():Id { return $this->eventId; } |
| 72 | |
| 73 | /** |
| 74 | * Get origin time as DateTime obj |
| 75 | * |
| 76 | * @return \DateTime origin time as DateTime obj |
| 77 | */ |
| 78 | public function originTimeObj():\DateTime{ return $this->originTimeUTC; } |
| 79 | |
| 80 | /** |
| 81 | * Get UTC origin time |
| 82 | * |
| 83 | * @return int UTC Origin time in YYYY-mm-ddTHH:mm:ss |
| 84 | */ |
| 85 | public function originTimeUTC():string { return $this->originTimeUTC->format('Y-m-d\TH:i:s'); } |
| 86 | |
| 87 | /** |
| 88 | * Get UTC origin time |
| 89 | * |
| 90 | * @return int UTC Origin time in YYYY-mm-ddTHH:mm:ss |
| 91 | */ |
| 92 | public function originTimeUTCISO8601():string { return $this->originTimeUTC->format('c'); } |
| 93 | |
| 94 | /** |
| 95 | * Get magnitude |
| 96 | * |
| 97 | * @return Magnitude Magnitude obj |
| 98 | */ |
| 99 | public function magnitude():Magnitude { return $this->magnitude; } |
| 100 | |
| 101 | /** |
| 102 | * Get epicenter |
| 103 | * |
| 104 | * @return Epicenter Epicenter obj |
| 105 | */ |
| 106 | public function epicenter():Epicenter { return $this->epicenter; } |
| 107 | |
| 108 | /** |
| 109 | * Get location |
| 110 | * |
| 111 | * @return Location Location obj |
| 112 | */ |
| 113 | public function location():Location { return $this->location; } |
| 114 | |
| 115 | /** |
| 116 | * Get author |
| 117 | * |
| 118 | * @return Author Author obj |
| 119 | */ |
| 120 | public function author():?Author { return $this->author; } |
| 121 | |
| 122 | /** |
| 123 | * Get event type |
| 124 | * |
| 125 | * @return EventType EventType obj |
| 126 | */ |
| 127 | public function eventType():?EventType{ return $this->eventType; } |
| 128 | } |