Code Duplication    Length = 103-103 lines in 2 locations

src/Mailgun/Model/Domain/CreateResponse.php 1 location

@@ 17-119 (lines=103) @@
14
/**
15
 * @author Tobias Nyholm <[email protected]>
16
 */
17
final class CreateResponse implements ApiResponse
18
{
19
    /**
20
     * @var string
21
     */
22
    private $message;
23
24
    /**
25
     * @var Domain
26
     */
27
    private $domain;
28
29
    /**
30
     * @var DnsRecord[]
31
     */
32
    private $inboundDnsRecords;
33
34
    /**
35
     * @var DnsRecord[]
36
     */
37
    private $outboundDnsRecords;
38
39
    /**
40
     * @param array $data
41
     *
42
     * @return self
43
     */
44
    public static function create(array $data)
45
    {
46
        $rx = [];
47
        $tx = [];
48
        $domain = null;
49
        $message = null;
50
51
        if (isset($data['domain'])) {
52
            $domain = Domain::create($data['domain']);
53
        }
54
55
        if (isset($data['message'])) {
56
            $message = $data['message'];
57
        }
58
59
        if (isset($data['receiving_dns_records'])) {
60
            foreach ($data['receiving_dns_records'] as $item) {
61
                $rx[] = DnsRecord::create($item);
62
            }
63
        }
64
65
        if (isset($data['sending_dns_records'])) {
66
            foreach ($data['sending_dns_records'] as $item) {
67
                $tx[] = DnsRecord::create($item);
68
            }
69
        }
70
71
        return new self($domain, $rx, $tx, $message);
72
    }
73
74
    /**
75
     * @param Domain      $domainInfo
76
     * @param DnsRecord[] $rxRecords
77
     * @param DnsRecord[] $txRecords
78
     * @param string      $message
79
     */
80
    private function __construct(Domain $domainInfo, array $rxRecords, array $txRecords, $message)
81
    {
82
        $this->domain = $domainInfo;
83
        $this->inboundDnsRecords = $rxRecords;
84
        $this->outboundDnsRecords = $txRecords;
85
        $this->message = $message;
86
    }
87
88
    /**
89
     * @return Domain
90
     */
91
    public function getDomain()
92
    {
93
        return $this->domain;
94
    }
95
96
    /**
97
     * @return DnsRecord[]
98
     */
99
    public function getInboundDNSRecords()
100
    {
101
        return $this->inboundDnsRecords;
102
    }
103
104
    /**
105
     * @return DnsRecord[]
106
     */
107
    public function getOutboundDNSRecords()
108
    {
109
        return $this->outboundDnsRecords;
110
    }
111
112
    /**
113
     * @return string
114
     */
115
    public function getMessage()
116
    {
117
        return $this->message;
118
    }
119
}
120

src/Mailgun/Model/Domain/VerifyResponse.php 1 location

@@ 17-119 (lines=103) @@
14
/**
15
 * @author Maxim Zasorin <[email protected]>
16
 */
17
final class VerifyResponse implements ApiResponse
18
{
19
    /**
20
     * @var Domain
21
     */
22
    private $domain;
23
24
    /**
25
     * @var string
26
     */
27
    private $message;
28
29
    /**
30
     * @var DnsRecord[]
31
     */
32
    private $inboundDnsRecords;
33
34
    /**
35
     * @var DnsRecord[]
36
     */
37
    private $outboundDnsRecords;
38
39
    /**
40
     * @param array $data
41
     *
42
     * @return self
43
     */
44
    public static function create(array $data)
45
    {
46
        $rx = [];
47
        $tx = [];
48
        $domain = null;
49
        $message = null;
50
51
        if (isset($data['domain'])) {
52
            $domain = Domain::create($data['domain']);
53
        }
54
55
        if (isset($data['message'])) {
56
            $message = $data['message'];
57
        }
58
59
        if (isset($data['receiving_dns_records'])) {
60
            foreach ($data['receiving_dns_records'] as $item) {
61
                $rx[] = DnsRecord::create($item);
62
            }
63
        }
64
65
        if (isset($data['sending_dns_records'])) {
66
            foreach ($data['sending_dns_records'] as $item) {
67
                $tx[] = DnsRecord::create($item);
68
            }
69
        }
70
71
        return new self($domain, $rx, $tx, $message);
72
    }
73
74
    /**
75
     * @param Domain      $domainInfo
76
     * @param DnsRecord[] $rxRecords
77
     * @param DnsRecord[] $txRecords
78
     * @param string      $message
79
     */
80
    private function __construct(Domain $domainInfo, array $rxRecords, array $txRecords, $message)
81
    {
82
        $this->domain = $domainInfo;
83
        $this->inboundDnsRecords = $rxRecords;
84
        $this->outboundDnsRecords = $txRecords;
85
        $this->message = $message;
86
    }
87
88
    /**
89
     * @return Domain
90
     */
91
    public function getDomain()
92
    {
93
        return $this->domain;
94
    }
95
96
    /**
97
     * @return DnsRecord[]
98
     */
99
    public function getInboundDNSRecords()
100
    {
101
        return $this->inboundDnsRecords;
102
    }
103
104
    /**
105
     * @return DnsRecord[]
106
     */
107
    public function getOutboundDNSRecords()
108
    {
109
        return $this->outboundDnsRecords;
110
    }
111
112
    /**
113
     * @return string
114
     */
115
    public function getMessage()
116
    {
117
        return $this->message;
118
    }
119
}
120