Phone   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 42
c 0
b 0
f 0
wmc 6
lcom 1
cbo 2
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A __toString() 0 4 1
A countryCode() 0 4 1
A number() 0 4 1
A render() 0 7 2
1
<?php
2
3
namespace Shrikeh\PagerDuty\Entity\ContactMethod\Resource;
4
5
use Shrikeh\PagerDuty\Entity\ContactMethod\Resource;
6
use Shrikeh\PagerDuty\Entity\ContactMethod\Resource\Blacklisted;
7
use Shrikeh\PagerDuty\Entity\ContactMethod\Resource\Blacklistable;
8
use Shrikeh\PagerDuty\Entity\ContactMethod\Resource\Type;
9
10
final class Phone implements Resource, Blacklistable
11
{
12
    use Type;
13
    use Blacklisted;
14
15
    private $countryCode;
16
17
    private $number;
18
19
    public function __construct(
20
        $number,
21
        $countryCode,
22
        $blacklisted = false
23
    ) {
24
        $this->number = $number;
25
        $this->countryCode = $countryCode;
26
        $this->blacklisted = $blacklisted;
27
    }
28
29
    public function __toString()
30
    {
31
        return $this->render();
32
    }
33
34
    public function countryCode()
35
    {
36
        return $this->countryCode;
37
    }
38
39
    public function number()
40
    {
41
        return $this->number;
42
    }
43
44
    public function render($prependCountryCode = true)
45
    {
46
        if ($prependCountryCode) {
47
            return sprintf('+%d%d', $this->countryCode, $this->number);
48
        }
49
        return $this->number;
50
    }
51
}
52