DomainIdentity   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getDomain() 0 4 1
1
<?php
2
3
namespace PeterNijssen\Ses\Model;
4
5
use PeterNijssen\Ses\Exception\InvalidIdentityException;
6
7
/**
8
 * Domain identity
9
 */
10
class DomainIdentity extends SesIdentity implements IdentityInterface
11
{
12
    /**
13
     * Domain identity constructor.
14
     *
15
     * @param string $identity domain
16
     *
17
     * @throws InvalidIdentityException
18
     */
19 12
    public function __construct($identity)
20
    {
21 12
        if (!preg_match('/^((\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,32}|[0-9]{1,32})(\]?))$/', $identity)
22 12
        ) {
23 1
            throw new InvalidIdentityException("The identity is not a valid domain");
24
        }
25
26 12
        $this->identity = $identity;
27 12
    }
28
29
    /**
30
     * Get the domain for this identity
31
     *
32
     * @return string
33
     */
34 4
    public function getDomain()
35
    {
36 4
        return $this->identity;
37
    }
38
}
39