Response   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 59
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A parseResult() 0 9 2
A status() 0 4 1
A iso2() 0 4 1
A iso3() 0 4 1
A name() 0 4 1
1
<?php
2
3
namespace Ip2c\Http;
4
5
class Response
6
{
7
    private $status;
8
    private $iso2;
9
    private $iso3;
10
    private $name;
11
12 9
    public function __construct($response)
13
    {
14 9
        $this->parseResult($response);
15 9
    }
16
17
    /**
18
     * @param $response
19
     * @return Response
20
     * @throws \Exception
21
     */
22 9
    private function parseResult($response)
23
    {
24 9
        $responseParts = explode(';', $response);
25 9
        if (count($responseParts) == 4) {
26 9
            list($this->status, $this->iso2, $this->iso3, $this->name) = $responseParts;
27 9
        } else {
28 1
            throw new \Exception('Inconsistent response from Ip2c', 1);
29
        }
30 9
    }
31
32
    /**
33
     * @return int
34
     */
35 4
    public function status()
36
    {
37 4
        return $this->status;
38
    }
39
40
    /**
41
     * @return string
42
     */
43 4
    public function iso2()
44
    {
45 4
        return $this->iso2;
46
    }
47
48
    /**
49
     * @return string
50
     */
51 4
    public function iso3()
52
    {
53 4
        return $this->iso3;
54
    }
55
56
    /**
57
     * @return string
58
     */
59 4
    public function name()
60
    {
61 4
        return $this->name;
62
    }
63
}
64