Sms   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A __toString() 0 4 1
A countryCode() 0 4 1
A number() 0 4 1
A enabled() 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 Sms 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
        $enabled,
23
        $blacklisted = false
24
    ) {
25
        $this->number = $number;
26
        $this->countryCode = $countryCode;
27
        $this->enabled = $enabled;
0 ignored issues
show
Bug introduced by
The property enabled does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
28
        $this->blacklisted = $blacklisted;
29
    }
30
31
    public function __toString()
32
    {
33
        return $this->render();
34
    }
35
36
    public function countryCode()
37
    {
38
        return $this->countryCode;
39
    }
40
41
    public function number()
42
    {
43
        return $this->number;
44
    }
45
46
    public function enabled()
47
    {
48
        return $this->enabled;
49
    }
50
51
    public function render($prependCountryCode = true)
52
    {
53
        if ($prependCountryCode) {
54
            return sprintf('+%d%d', $this->countryCode, $this->number);
55
        }
56
        return $this->number;
57
    }
58
}
59