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

OpenTracking::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
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
/**
15
 * Represents a single Open Tracking setting for a domain tracking.
16
 *
17
 * @author Artem Bondarenko <[email protected]>
18
 */
19
final class OpenTracking
20
{
21
    private $active;
22
23 3
    public static function create(array $data): self
24
    {
25 3
        $active = $data['active'] ?? null;
26 3
        $model = new self();
27 3
        $model->active = $active ? 'yes' : 'no';
28
29 3
        return $model;
30
    }
31
32 3
    private function __construct()
33
    {
34 3
    }
35
36
    /**
37
     * @return string
38
     */
39 3
    public function getActive(): ?string
40
    {
41 3
        return $this->active;
42
    }
43
44 3
    public function isActive(): bool
45
    {
46 3
        return 'yes' === $this->getActive();
47
    }
48
}
49