Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
90.00% covered (success)
90.00%
9 / 10
57.14% covered (warning)
57.14%
4 / 7
75.00% covered (warning)
75.00%
3 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
MultiInstance
100.00% covered (success)
100.00%
11 / 11
90.00% covered (success)
90.00%
9 / 10
57.14% covered (warning)
57.14%
4 / 7
100.00% covered (success)
100.00%
4 / 4
8.83
100.00% covered (success)
100.00%
1 / 1
 rawXMLCatalogs
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 DOMCatalogs
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 fetch
100.00% covered (success)
100.00%
3 / 3
75.00% covered (warning)
75.00%
3 / 4
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
2.50
 parse
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
4 / 4
33.33% covered (danger)
33.33%
1 / 3
100.00% covered (success)
100.00%
1 / 1
3.19
1<?php
2namespace Fdsn\Webservices\Catalog;
3
4use Fdsn\Webservices\Webservice as Fdsnws_Webservice;
5
6/**
7 * PHP library to access FDSN Webservices and request Catalogs
8 */
9class 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}