Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
90.91% covered (success)
90.91%
10 / 11
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%
12 / 12
90.91% covered (success)
90.91%
10 / 11
57.14% covered (warning)
57.14%
4 / 7
100.00% covered (success)
100.00%
4 / 4
10.86
100.00% covered (success)
100.00%
1 / 1
 rawXMLContributors
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
 DOMContributors
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%
4 / 4
80.00% covered (warning)
80.00%
4 / 5
50.00% covered (danger)
50.00%
1 / 2
100.00% covered (success)
100.00%
1 / 1
4.12
 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\Contributor;
3
4use Fdsn\Webservices\Webservice as Fdsnws_Webservice;
5
6/**
7 * PHP library to access FDSN Webservices and request Contributors
8 */
9class MultiInstance extends Fdsnws_Webservice {
10
11    private string $xmlResults;
12    private \DOMDocument $DOMResults;
13
14    /**
15     * Get RAW Contributors XML String
16     * @return string    Get RAW Contributors XML String
17     */
18        public function rawXMLContributors():string { return $this->xmlResults; }
19
20    /**
21     * Get Contributors parsed in a DOM Document
22     * @return \DOMDocument Get Contributors parsed in a DOMDocument
23     */
24        public function DOMContributors():\DOMDocument{ return $this->DOMResults; }
25
26    /**
27     * Fetch contributors (xml document) from selected FDSN server
28     * 
29     * @return int number of catalogs found
30     */
31    public function fetch():int {
32        if( ! $this->fdsnSupportedVersion() ){
33            // @codeCoverageIgnoreStart
34            throw new \ValueError(sprintf("[%s] Error fetching FDSN version from server %s", __METHOD__, $this->fdsnServer));
35            // @codeCoverageIgnoreEnd
36        }
37
38        $xmlResponse = $this->getFetch($this->webserviceFullPath . '/contributors');
39
40        $this->xmlResults = ( $this->parse($xmlResponse) > 0 ) ? $xmlResponse : '';
41
42        return $this->numRows();
43    }
44
45    /**
46     * Parse XML Contributors and store it into a DOM Document AND all values found into an Iterable array
47     * 
48     * @return int number of contributors found
49     */
50    private function parse(string $xmlResponse):int{
51        $this->DOMResults = new \DOMDocument('1.0', 'UTF-8');
52        $this->DOMResults->loadXML($xmlResponse);
53
54        $contributors = $this->DOMResults->getElementsByTagName('Contributor');
55        foreach($contributors as $name)
56            $this->arrayOfResults[] = new Struct(trim($name->nodeValue));
57    
58        return $this->numRows();
59    }
60}