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

ClickTracking::isActive()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
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
/**
15
 * Represents a single Click Tracking setting for a domain tracking.
16
 *
17
 * @author Artem Bondarenko <[email protected]>
18
 */
19
final class ClickTracking
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 = 'htmlonly' === $active ? $active : ($active ? 'yes' : 'no');
28
29 3
        return $model;
30
    }
31
32 3
    private function __construct()
33
    {
34 3
    }
35
36 3
    public function getActive(): ?string
37
    {
38 3
        return $this->active;
39
    }
40
41 3
    public function isActive(): bool
42
    {
43 3
        return 'yes' === $this->getActive();
44
    }
45
46 1
    public function isHtmlOnly(): bool
47
    {
48 1
        return 'htmlonly' === $this->getActive();
49
    }
50
}
51