Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
80.95% |
17 / 21 |
|
73.33% |
11 / 15 |
|
14.29% |
2 / 14 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Json | |
80.95% |
17 / 21 |
|
73.33% |
11 / 15 |
|
14.29% |
2 / 14 |
|
0.00% |
0 / 1 |
37.86 | |
0.00% |
0 / 1 |
| fetch | |
80.95% |
17 / 21 |
|
73.33% |
11 / 15 |
|
14.29% |
2 / 14 |
|
0.00% |
0 / 1 |
37.86 | |||
| 1 | <?php |
| 2 | namespace Hsit\Webservice\Event\ThematicEffect; |
| 3 | |
| 4 | use Hsit\Webservice\Event\ThematicEffect as HWE_ThematicEffect; |
| 5 | use Fdsn\DataStructure\Id as DS_Id; |
| 6 | use Fdsn\DataStructure\LatLon as DS_LatLon; |
| 7 | |
| 8 | /** |
| 9 | * Fetch Json thematic effect data from HSIT portal |
| 10 | * |
| 11 | * @param Fdsn\DataStructure\Id $fdsnQuakeId Id quake to scan for data |
| 12 | * @param string $thematicEffect study (now only ????? are supported) |
| 13 | * @param string $localFileFullPath base url to fetch local file (filepath will be: baseUrl/<hsit_filename>.txt) |
| 14 | */ |
| 15 | class Json extends HWE_ThematicEffect { |
| 16 | protected const fileExtension = 'json'; |
| 17 | |
| 18 | /** |
| 19 | * fetch data from url (remote or local - if $localFileFullPath is set in __construct) |
| 20 | * |
| 21 | * @return int number of data found |
| 22 | */ |
| 23 | public function fetch():int{ |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 28 | return -1; |
| 29 | |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 31 | return -2; |
| 32 | |
| 33 | if( ! array_key_exists('MacroseismicData', $data['Quakes'][$this->idQuake->value()]) ) |
| 34 | return -3; |
| 35 | |
| 36 | if( ! array_key_exists('MDPs', $data['Quakes'][$this->idQuake->value()]['MacroseismicData']) ) |
| 37 | return -4; |
| 38 | |
| 39 | $mdpsArray = $data['Quakes'][$this->idQuake->value()]['MacroseismicData']['MDPs']; |
| 40 | |
| 41 | foreach($mdpsArray as $mdp){ |
| 42 | $this->places[] = array( |
| 43 | 'point' => new DS_LatLon($mdp['TerritorialUnit']['Coordinates']['Latitude'], $mdp['TerritorialUnit']['Coordinates']['Longitude']), |
| 44 | 'percentage' => $mdp['Value'], |
| 45 | 'reports' => $mdp['QuestNumber']['Total'], |
| 46 | 'felt' => $mdp['QuestNumber']['Felt'], |
| 47 | 'notFelt' => $mdp['QuestNumber']['NotFelt'], |
| 48 | 'place' => $mdp['TerritorialUnit']['Name'] |
| 49 | |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | return count($this->places); |
| 54 | } |
| 55 | } |
| 56 | ?> |
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.
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 28 | return -1; |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 31 | return -2; |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 33 | if( ! array_key_exists('MacroseismicData', $data['Quakes'][$this->idQuake->value()]) ) |
| 34 | return -3; |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 33 | if( ! array_key_exists('MacroseismicData', $data['Quakes'][$this->idQuake->value()]) ) |
| 36 | if( ! array_key_exists('MDPs', $data['Quakes'][$this->idQuake->value()]['MacroseismicData']) ) |
| 37 | return -4; |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 33 | if( ! array_key_exists('MacroseismicData', $data['Quakes'][$this->idQuake->value()]) ) |
| 36 | if( ! array_key_exists('MDPs', $data['Quakes'][$this->idQuake->value()]['MacroseismicData']) ) |
| 39 | $mdpsArray = $data['Quakes'][$this->idQuake->value()]['MacroseismicData']['MDPs']; |
| 40 | |
| 41 | foreach($mdpsArray as $mdp){ |
| 41 | foreach($mdpsArray as $mdp){ |
| 41 | foreach($mdpsArray as $mdp){ |
| 42 | $this->places[] = array( |
| 43 | 'point' => new DS_LatLon($mdp['TerritorialUnit']['Coordinates']['Latitude'], $mdp['TerritorialUnit']['Coordinates']['Longitude']), |
| 41 | foreach($mdpsArray as $mdp){ |
| 41 | foreach($mdpsArray as $mdp){ |
| 42 | $this->places[] = array( |
| 43 | 'point' => new DS_LatLon($mdp['TerritorialUnit']['Coordinates']['Latitude'], $mdp['TerritorialUnit']['Coordinates']['Longitude']), |
| 44 | 'percentage' => $mdp['Value'], |
| 45 | 'reports' => $mdp['QuestNumber']['Total'], |
| 46 | 'felt' => $mdp['QuestNumber']['Felt'], |
| 47 | 'notFelt' => $mdp['QuestNumber']['NotFelt'], |
| 48 | 'place' => $mdp['TerritorialUnit']['Name'] |
| 49 | |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | return count($this->places); |
| 54 | } |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 33 | if( ! array_key_exists('MacroseismicData', $data['Quakes'][$this->idQuake->value()]) ) |
| 36 | if( ! array_key_exists('MDPs', $data['Quakes'][$this->idQuake->value()]['MacroseismicData']) ) |
| 39 | $mdpsArray = $data['Quakes'][$this->idQuake->value()]['MacroseismicData']['MDPs']; |
| 40 | |
| 41 | foreach($mdpsArray as $mdp){ |
| 41 | foreach($mdpsArray as $mdp){ |
| 41 | foreach($mdpsArray as $mdp){ |
| 42 | $this->places[] = array( |
| 43 | 'point' => new DS_LatLon($mdp['TerritorialUnit']['Coordinates']['Latitude'], $mdp['TerritorialUnit']['Coordinates']['Longitude']), |
| 44 | 'percentage' => $mdp['Value'], |
| 45 | 'reports' => $mdp['QuestNumber']['Total'], |
| 46 | 'felt' => $mdp['QuestNumber']['Felt'], |
| 47 | 'notFelt' => $mdp['QuestNumber']['NotFelt'], |
| 48 | 'place' => $mdp['TerritorialUnit']['Name'] |
| 49 | |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | return count($this->places); |
| 54 | } |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 33 | if( ! array_key_exists('MacroseismicData', $data['Quakes'][$this->idQuake->value()]) ) |
| 36 | if( ! array_key_exists('MDPs', $data['Quakes'][$this->idQuake->value()]['MacroseismicData']) ) |
| 39 | $mdpsArray = $data['Quakes'][$this->idQuake->value()]['MacroseismicData']['MDPs']; |
| 40 | |
| 41 | foreach($mdpsArray as $mdp){ |
| 41 | foreach($mdpsArray as $mdp){ |
| 42 | $this->places[] = array( |
| 43 | 'point' => new DS_LatLon($mdp['TerritorialUnit']['Coordinates']['Latitude'], $mdp['TerritorialUnit']['Coordinates']['Longitude']), |
| 44 | 'percentage' => $mdp['Value'], |
| 45 | 'reports' => $mdp['QuestNumber']['Total'], |
| 46 | 'felt' => $mdp['QuestNumber']['Felt'], |
| 47 | 'notFelt' => $mdp['QuestNumber']['NotFelt'], |
| 48 | 'place' => $mdp['TerritorialUnit']['Name'] |
| 49 | |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | return count($this->places); |
| 54 | } |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 28 | return -1; |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 31 | return -2; |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 33 | if( ! array_key_exists('MacroseismicData', $data['Quakes'][$this->idQuake->value()]) ) |
| 34 | return -3; |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 33 | if( ! array_key_exists('MacroseismicData', $data['Quakes'][$this->idQuake->value()]) ) |
| 36 | if( ! array_key_exists('MDPs', $data['Quakes'][$this->idQuake->value()]['MacroseismicData']) ) |
| 37 | return -4; |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 33 | if( ! array_key_exists('MacroseismicData', $data['Quakes'][$this->idQuake->value()]) ) |
| 36 | if( ! array_key_exists('MDPs', $data['Quakes'][$this->idQuake->value()]['MacroseismicData']) ) |
| 39 | $mdpsArray = $data['Quakes'][$this->idQuake->value()]['MacroseismicData']['MDPs']; |
| 40 | |
| 41 | foreach($mdpsArray as $mdp){ |
| 41 | foreach($mdpsArray as $mdp){ |
| 41 | foreach($mdpsArray as $mdp){ |
| 42 | $this->places[] = array( |
| 43 | 'point' => new DS_LatLon($mdp['TerritorialUnit']['Coordinates']['Latitude'], $mdp['TerritorialUnit']['Coordinates']['Longitude']), |
| 41 | foreach($mdpsArray as $mdp){ |
| 41 | foreach($mdpsArray as $mdp){ |
| 42 | $this->places[] = array( |
| 43 | 'point' => new DS_LatLon($mdp['TerritorialUnit']['Coordinates']['Latitude'], $mdp['TerritorialUnit']['Coordinates']['Longitude']), |
| 44 | 'percentage' => $mdp['Value'], |
| 45 | 'reports' => $mdp['QuestNumber']['Total'], |
| 46 | 'felt' => $mdp['QuestNumber']['Felt'], |
| 47 | 'notFelt' => $mdp['QuestNumber']['NotFelt'], |
| 48 | 'place' => $mdp['TerritorialUnit']['Name'] |
| 49 | |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | return count($this->places); |
| 54 | } |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 33 | if( ! array_key_exists('MacroseismicData', $data['Quakes'][$this->idQuake->value()]) ) |
| 36 | if( ! array_key_exists('MDPs', $data['Quakes'][$this->idQuake->value()]['MacroseismicData']) ) |
| 39 | $mdpsArray = $data['Quakes'][$this->idQuake->value()]['MacroseismicData']['MDPs']; |
| 40 | |
| 41 | foreach($mdpsArray as $mdp){ |
| 41 | foreach($mdpsArray as $mdp){ |
| 41 | foreach($mdpsArray as $mdp){ |
| 42 | $this->places[] = array( |
| 43 | 'point' => new DS_LatLon($mdp['TerritorialUnit']['Coordinates']['Latitude'], $mdp['TerritorialUnit']['Coordinates']['Longitude']), |
| 44 | 'percentage' => $mdp['Value'], |
| 45 | 'reports' => $mdp['QuestNumber']['Total'], |
| 46 | 'felt' => $mdp['QuestNumber']['Felt'], |
| 47 | 'notFelt' => $mdp['QuestNumber']['NotFelt'], |
| 48 | 'place' => $mdp['TerritorialUnit']['Name'] |
| 49 | |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | return count($this->places); |
| 54 | } |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 24 | $jsonString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
| 25 | $data = json_decode($jsonString, true); |
| 26 | |
| 27 | if( ! array_key_exists('Quakes', $data) ) |
| 30 | if( ! array_key_exists($this->idQuake->value(), $data['Quakes']) ) |
| 33 | if( ! array_key_exists('MacroseismicData', $data['Quakes'][$this->idQuake->value()]) ) |
| 36 | if( ! array_key_exists('MDPs', $data['Quakes'][$this->idQuake->value()]['MacroseismicData']) ) |
| 39 | $mdpsArray = $data['Quakes'][$this->idQuake->value()]['MacroseismicData']['MDPs']; |
| 40 | |
| 41 | foreach($mdpsArray as $mdp){ |
| 41 | foreach($mdpsArray as $mdp){ |
| 42 | $this->places[] = array( |
| 43 | 'point' => new DS_LatLon($mdp['TerritorialUnit']['Coordinates']['Latitude'], $mdp['TerritorialUnit']['Coordinates']['Longitude']), |
| 44 | 'percentage' => $mdp['Value'], |
| 45 | 'reports' => $mdp['QuestNumber']['Total'], |
| 46 | 'felt' => $mdp['QuestNumber']['Felt'], |
| 47 | 'notFelt' => $mdp['QuestNumber']['NotFelt'], |
| 48 | 'place' => $mdp['TerritorialUnit']['Name'] |
| 49 | |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | return count($this->places); |
| 54 | } |