Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
Total | |
100.00% |
11 / 11 |
|
90.00% |
9 / 10 |
|
57.14% |
4 / 7 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
MultiInstance | |
100.00% |
11 / 11 |
|
90.00% |
9 / 10 |
|
57.14% |
4 / 7 |
|
100.00% |
4 / 4 |
8.83 | |
100.00% |
1 / 1 |
rawXMLCatalogs | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
DOMCatalogs | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
fetch | |
100.00% |
3 / 3 |
|
75.00% |
3 / 4 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
2.50 | |||
parse | |
100.00% |
6 / 6 |
|
100.00% |
4 / 4 |
|
33.33% |
1 / 3 |
|
100.00% |
1 / 1 |
3.19 |
1 | <?php |
2 | namespace Fdsn\Webservices\Catalog; |
3 | |
4 | use Fdsn\Webservices\Webservice as Fdsnws_Webservice; |
5 | |
6 | /** |
7 | * PHP library to access FDSN Webservices and request Catalogs |
8 | */ |
9 | class MultiInstance extends Fdsnws_Webservice { |
10 | |
11 | private string $xmlResults; |
12 | private \DOMDocument $DOMResults; |
13 | |
14 | /** |
15 | * Get RAW Catalogs XML String |
16 | * @return string Get RAW Catalogs XML String |
17 | */ |
18 | public function rawXMLCatalogs():string { return $this->xmlResults; } |
19 | |
20 | /** |
21 | * Get Catalogs parsed in a DOM Document |
22 | * @return \DOMDocument Get Catalogs parsed in a DOMDocument |
23 | */ |
24 | public function DOMCatalogs():\DOMDocument{ return $this->DOMResults; } |
25 | |
26 | /** |
27 | * Fetch catalogs (xml document) from selected FDSN server |
28 | * |
29 | * @return int number of catalogs found |
30 | */ |
31 | public function fetch():int{ |
32 | $xmlResponse = $this->getFetch($this->webserviceFullPath . '/catalogs'); |
33 | |
34 | $this->xmlResults = ( $this->parse($xmlResponse) > 0 ) ? $xmlResponse : ''; |
35 | |
36 | return $this->numRows(); |
37 | } |
38 | |
39 | /** |
40 | * Parse XML Catalogs and store it into a DOM Document AND all values found into an Iterable array |
41 | * |
42 | * @param string $xmlResponse xml document got by API request |
43 | * |
44 | * @return int number of catalogs found |
45 | */ |
46 | private function parse(string $xmlResponse):int{ |
47 | $this->DOMResults = new \DOMDocument('1.0', 'UTF-8'); |
48 | $this->DOMResults->loadXML($xmlResponse); |
49 | |
50 | $catalogsNode = $this->DOMResults->getElementsByTagName('Catalog'); |
51 | foreach($catalogsNode as $name) |
52 | $this->arrayOfResults[] = new Struct(trim($name->nodeValue)); |
53 | |
54 | return $this->numRows(); |
55 | } |
56 | |
57 | |
58 | } |
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 | public function DOMCatalogs():\DOMDocument{ return $this->DOMResults; } |
32 | $xmlResponse = $this->getFetch($this->webserviceFullPath . '/catalogs'); |
33 | |
34 | $this->xmlResults = ( $this->parse($xmlResponse) > 0 ) ? $xmlResponse : ''; |
34 | $this->xmlResults = ( $this->parse($xmlResponse) > 0 ) ? $xmlResponse : ''; |
34 | $this->xmlResults = ( $this->parse($xmlResponse) > 0 ) ? $xmlResponse : ''; |
34 | $this->xmlResults = ( $this->parse($xmlResponse) > 0 ) ? $xmlResponse : ''; |
35 | |
36 | return $this->numRows(); |
37 | } |
46 | private function parse(string $xmlResponse):int{ |
47 | $this->DOMResults = new \DOMDocument('1.0', 'UTF-8'); |
48 | $this->DOMResults->loadXML($xmlResponse); |
49 | |
50 | $catalogsNode = $this->DOMResults->getElementsByTagName('Catalog'); |
51 | foreach($catalogsNode as $name) |
51 | foreach($catalogsNode as $name) |
51 | foreach($catalogsNode as $name) |
52 | $this->arrayOfResults[] = new Struct(trim($name->nodeValue)); |
51 | foreach($catalogsNode as $name) |
52 | $this->arrayOfResults[] = new Struct(trim($name->nodeValue)); |
53 | |
54 | return $this->numRows(); |
55 | } |
18 | public function rawXMLCatalogs():string { return $this->xmlResults; } |