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

HttpReader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 84.62%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 35
rs 10
c 0
b 0
f 0
ccs 11
cts 13
cp 0.8462

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getResponseCode() 0 8 1
A getUrl() 0 4 1
A getContents() 0 4 1
A extractResponseCode() 0 4 1
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