Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
Total | |
100.00% |
17 / 17 |
|
100.00% |
7 / 7 |
|
50.00% |
2 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
Xml | |
100.00% |
17 / 17 |
|
100.00% |
7 / 7 |
|
50.00% |
2 / 4 |
|
100.00% |
1 / 1 |
4.12 | |
100.00% |
1 / 1 |
fetch | |
100.00% |
17 / 17 |
|
100.00% |
7 / 7 |
|
50.00% |
2 / 4 |
|
100.00% |
1 / 1 |
4.12 |
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 XML 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 Xml extends HWE_ThematicEffect { |
16 | protected const fileExtension = 'xml'; |
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 | $xmlString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
25 | $xmlData = new \DomDocument(); |
26 | $xmlData->loadXML($xmlString); |
27 | |
28 | $mdpsNode = $xmlData->getElementsByTagName('MDPs')->item(0); |
29 | $numRows = count($mdpsNode->getElementsByTagName('MDP')); |
30 | $mdpNodes = $xmlData->getElementsByTagName('MDP'); |
31 | |
32 | for($i = 0; $i < $numRows; $i++){ |
33 | $mdp = $mdpNodes->item($i); |
34 | $this->places[] = array( |
35 | 'point' => new DS_LatLon($mdp->getElementsByTagName('Latitude')->item(0)->nodeValue, $mdp->getElementsByTagName('Longitude')->item(0)->nodeValue), |
36 | 'percentage' => $mdp->getElementsByTagName('Value')->item(0)->nodeValue, |
37 | 'reports' => $mdp->getElementsByTagName('Total')->item(0)->nodeValue, |
38 | 'felt' => $mdp->getElementsByTagName('Felt')->item(0)->nodeValue, |
39 | 'notFelt' => $mdp->getElementsByTagName('NotFelt')->item(0)->nodeValue, |
40 | 'place' => $mdp->getElementsByTagName('Name')->item(0)->nodeValue |
41 | ); |
42 | } |
43 | |
44 | return count($this->places); |
45 | } |
46 | } |
47 | ?> |
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.
24 | $xmlString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
24 | $xmlString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
24 | $xmlString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
24 | $xmlString = is_null($this->localFileFullPath) ? $this->fetchFromUrl() : $this->fetchFromLocalPath(); |
25 | $xmlData = new \DomDocument(); |
26 | $xmlData->loadXML($xmlString); |
27 | |
28 | $mdpsNode = $xmlData->getElementsByTagName('MDPs')->item(0); |
29 | $numRows = count($mdpsNode->getElementsByTagName('MDP')); |
30 | $mdpNodes = $xmlData->getElementsByTagName('MDP'); |
31 | |
32 | for($i = 0; $i < $numRows; $i++){ |
32 | for($i = 0; $i < $numRows; $i++){ |
33 | $mdp = $mdpNodes->item($i); |
32 | for($i = 0; $i < $numRows; $i++){ |
44 | return count($this->places); |
45 | } |