PhoneNumberDetails   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 92.59%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 25
c 1
b 0
f 0
dl 0
loc 73
ccs 25
cts 27
cp 0.9259
rs 10
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getDistrict() 0 5 1
A getArea() 0 5 1
A getProvince() 0 5 1
A checkLocationDetails() 0 4 2
A getOperator() 0 3 1
A getNumber() 0 3 1
A getType() 0 3 1
A __construct() 0 10 2
1
<?php
2
3
namespace APiChef\SlPhoneNumber;
4
5
class PhoneNumberDetails
6
{
7
    /** @var string */
8
    private $number;
9
10
    /** @var string */
11
    private $type;
12
13
    /** @var string */
14
    private $operator;
15
16
    /** @var string */
17
    private $province = null;
18
19
    /** @var string */
20
    private $district = null;
21
22
    /** @var string */
23
    private $area = null;
24
25 48
    public function __construct(string $number, string $type, string $operator, array $location = null)
26
    {
27 48
        $this->number = $number;
28 48
        $this->type = $type;
29 48
        $this->operator = $operator;
30
31 48
        if ($location !== null) {
32 21
            $this->province = $location['province'];
33 21
            $this->district = $location['district'];
34 21
            $this->area = $location['area'];
35
        }
36 48
    }
37
38 18
    public function getNumber(): string
39
    {
40 18
        return $this->number;
41
    }
42
43
    public function getType(): string
44
    {
45
        return $this->type;
46
    }
47
48 3
    public function getOperator(): string
49
    {
50 3
        return $this->operator;
51
    }
52
53 6
    public function getProvince(): string
54
    {
55 6
        $this->checkLocationDetails();
56
57 3
        return $this->province;
58
    }
59
60 6
    public function getDistrict(): string
61
    {
62 6
        $this->checkLocationDetails();
63
64 3
        return $this->district;
65
    }
66
67 6
    public function getArea(): string
68
    {
69 6
        $this->checkLocationDetails();
70
71 3
        return $this->area;
72
    }
73
74 12
    private function checkLocationDetails(): void
75
    {
76 12
        if ($this->province === null) {
77 9
            throw new \LogicException('Can not read location details form mobile number');
78
        }
79 3
    }
80
}
81