GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Pull Request — master (#3)
by Sascha
09:47
created

Address   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 72
ccs 12
cts 14
cp 0.8571
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getAddress() 0 4 1
A getName() 0 4 1
A isValid() 0 4 1
A equals() 0 4 1
A jsonSerialize() 0 4 1
1
<?php
2
3
namespace Conversio\Mail\Address;
4
5
/**
6
 * Class Address
7
 * @package Conversio\Mail\Address
8
 */
9
class Address implements \JsonSerializable
10
{
11
    /**
12
     * @var string $address
13
     */
14
    protected $address;
15
16
    /**
17
     * @var string $name
18
     */
19
    private $name;
20
21
    /**
22
     * Address constructor.
23
     *
24
     * @param string $address
25
     * @param string $name
26
     */
27 11
    public function __construct(string $address, string $name = '')
28
    {
29 11
        $this->address = strtolower(trim($address));
30 11
        $this->name    = trim($name);
31 11
    }
32
33
    /**
34
     * @return string
35
     */
36 4
    public function getAddress(): string
37
    {
38 4
        return $this->address;
39
    }
40
41
    /**
42
     * @return string
43
     */
44 1
    public function getName(): string
45
    {
46 1
        return $this->name;
47
    }
48
49
    /**
50
     * @return boolean
51
     */
52 1
    public function isValid(): bool
53
    {
54 1
        return filter_var($this->address, FILTER_VALIDATE_EMAIL) !== false;
55
    }
56
57
    /**
58
     * Checks, if the given addresses are equal. this only includes the address, the name is being ignored
59
     *
60
     * @param Address $address
0 ignored issues
show
Documentation introduced by
Should the type for parameter $address not be \self?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
61
     *
62
     * @return bool
63
     */
64 3
    public function equals(self $address): bool
65
    {
66 3
        return $this->getAddress() === $address->getAddress();
67
    }
68
69
    /**
70
     * Specify data which should be serialized to JSON
71
     * @link  http://php.net/manual/en/jsonserializable.jsonserialize.php
72
     * @return mixed data which can be serialized by <b>json_encode</b>,
73
     * which is a value of any type other than a resource.
74
     * @since 5.4.0
75
     */
76
    public function jsonSerialize()
77
    {
78
        return get_object_vars($this);
79
    }
80
}