Completed
Push — master ( 27d579...87c59d )
by David
02:18
created

TrackingResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2013 Mailgun
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license. See the LICENSE file for details.
10
 */
11
12
namespace Mailgun\Model\Domain;
13
14
use Mailgun\Model\ApiResponse;
15
16
/**
17
 * @author Artem Bondarenko <[email protected]>
18
 */
19
final class TrackingResponse implements ApiResponse
20
{
21
    private $click;
22
    private $open;
23
    private $unsubscribe;
24
25 1
    public static function create(array $data): ?self
26
    {
27 1
        if (!isset($data['tracking'])) {
28
            return null;
29
        }
30
31 1
        $trackingSettings = $data['tracking'];
32
33 1
        $model = new self();
34 1
        $model->click = ClickTracking::create($trackingSettings['click'] ?? []);
35 1
        $model->open = OpenTracking::create($trackingSettings['open'] ?? []);
36 1
        $model->unsubscribe = UnsubscribeTracking::create($trackingSettings['unsubscribe'] ?? []);
37
38 1
        return $model;
39
    }
40
41 1
    private function __construct()
42
    {
43 1
    }
44
45 1
    public function getClick(): ClickTracking
46
    {
47 1
        return $this->click;
48
    }
49
50 1
    public function getOpen(): OpenTracking
51
    {
52 1
        return $this->open;
53
    }
54
55 1
    public function getUnsubscribe(): UnsubscribeTracking
56
    {
57 1
        return $this->unsubscribe;
58
    }
59
}
60