Completed
Push — master ( 054033...570bb7 )
by Jordi
02:43
created

Response::name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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