Completed
Push — master ( 305ae1...054033 )
by Jordi
03:35
created

Response   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

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