Completed
Push — master ( 522c84...893b4c )
by Tom
02:22
created

DownloaderProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 21
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getXml() 0 12 1
1
<?php
2
3
namespace NoaaCapAlerts\XmlProvider;
4
5
class DownloaderProvider implements XmlProvider
6
{
7
    protected $indexUrl;
8
9 2
    function __construct(string $indexUrl = 'http://alerts.weather.gov/cap/us.php?x=0')
10
    {
11 2
        $this->indexUrl = $indexUrl;
12 2
    }
13
14 1
    public function getXml() : string
15
    {
16
        $options = array(
17 1
            'http' => array(
18
                'header' => "User-agent: noaa-cap-parser',"
19
            ),
20
        );
21
22 1
        $context = stream_context_create($options);
23 1
        $xml = file_get_contents($this->indexUrl, false, $context);
24
25 1
        return $xml;
26
    }
27
}
28
29