Completed
Push — master ( a1ca1a...6a943d )
by David
01:56
created

Parts   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 0
dl 0
loc 69
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A create() 0 8 4
A getDisplayName() 0 4 1
A getDomain() 0 4 1
A getLocalPart() 0 4 1
1
<?php
2
3
/*
4
 * Copyright (C) 2013 Mailgun
5
 *
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace Mailgun\Model\EmailValidation;
11
12
/**
13
 * @author David Garcia <[email protected]>
14
 */
15
final class Parts
16
{
17
    /**
18
     * @var string|null
19
     */
20
    private $displayName;
21
22
    /**
23
     * @var string|null
24
     */
25
    private $domain;
26
27
    /**
28
     * @var string|null
29
     */
30
    private $localPart;
31
32
    /**
33
     * Parts constructor.
34
     *
35
     * @param string|null $displayName
36
     * @param string|null $domain
37
     * @param string|null $localPart
38
     */
39
    private function __construct($displayName, $domain, $localPart)
40
    {
41
        $this->displayName = $displayName;
42
        $this->domain = $domain;
43
        $this->localPart = $localPart;
44
    }
45
46
    /**
47
     * @param array $data
48
     *
49
     * @return Parts
50
     */
51
    public static function create(array $data)
52
    {
53
        return new self(
54
            (isset($data['display_name']) ? $data['display_name'] : null),
55
            (isset($data['domain']) ? $data['domain'] : null),
56
            (isset($data['local_part']) ? $data['local_part'] : null)
57
        );
58
    }
59
60
    /**
61
     * @return null|string
62
     */
63
    public function getDisplayName()
64
    {
65
        return $this->displayName;
66
    }
67
68
    /**
69
     * @return null|string
70
     */
71
    public function getDomain()
72
    {
73
        return $this->domain;
74
    }
75
76
    /**
77
     * @return null|string
78
     */
79
    public function getLocalPart()
80
    {
81
        return $this->localPart;
82
    }
83
}
84