ContactMethod   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 70
c 0
b 0
f 0
wmc 9
lcom 1
cbo 1
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A fromApi() 0 13 1
A __construct() 0 10 1
A __toString() 0 4 1
A method() 0 4 1
A resource() 0 4 1
A summary() 0 4 1
A self() 0 4 1
A label() 0 4 1
A blacklisted() 0 4 1
1
<?php
2
3
namespace Shrikeh\PagerDuty\Entity\ContactMethod;
4
5
use Psr\Http\Message\UriInterface;
6
use Shrikeh\PagerDuty\Entity\ContactMethod as ContactMethodInterface;
7
8
final class ContactMethod implements ContactMethodInterface
9
{
10
    private $resource;
11
12
    private $self;
13
14
    private $summary;
15
16
    private $label;
17
18
    public static function fromApi(
19
        Resource $resource,
20
        UriInterface $self,
21
        $summary,
22
        $label
23
    ) {
24
        return new static(
25
            $resource,
26
            $summary,
27
            $label,
28
            $self
29
        );
30
    }
31
32
    private function __construct(
33
        Resource $resource,
34
        $summary,
35
        $label,
0 ignored issues
show
Unused Code introduced by
The parameter $label is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
        UriInterface $self = null
37
    ) {
38
        $this->resource = $resource;
39
        $this->self = $self;
40
        $this->summary = $summary;
41
    }
42
43
    public function __toString()
44
    {
45
        return (string) $this->resource();
46
    }
47
48
    public function method()
49
    {
50
        return $this->resource()->type();
51
    }
52
53
    public function resource()
54
    {
55
        return $this->resource;
56
    }
57
58
    public function summary()
59
    {
60
        return $this->summary;
61
    }
62
63
    public function self()
64
    {
65
        return $this->self;
66
    }
67
68
    public function label()
69
    {
70
        return $this->label;
71
    }
72
73
    public function blacklisted()
74
    {
75
        return $this->blacklisted;
0 ignored issues
show
Bug introduced by
The property blacklisted 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...
76
    }
77
}
78