Completed
Push — master ( 64e8ff...9df0db )
by Derek
02:02
created

HttpReader::getContents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 2
cp 0
cc 1
eloc 1
nc 1
nop 0
crap 2
1
<?php
2
namespace Subreality\Dilmun\Anshar;
3
4
use Subreality\Dilmun\LoggedClassTrait;
5
6
class HttpReader
7
{
8
    use LoggedClassTrait;
9
10
    public $url;
11
12 3
    public function __construct($url)
13
    {
14 3
        $this->url = $url;
15 3
    }
16
17 2
    public function getResponseCode()
18
    {
19 2
        $headers = get_headers($this->url);
20
21 2
        $code = $this->extractResponseCode($headers);
22
23 2
        return $code;
24
    }
25
26 1
    public function getUrl()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
27
    {
28 1
        return $this->url;
29
    }
30
31
    public function getContents()
32
    {
33
        // TODO: write logic here
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
34
    }
35
36 2
    private function extractResponseCode($headers)
37
    {
38 2
        return substr($headers[0], 9, 3);
39
    }
40
}
41