Completed
Push — master ( 46f3eb...7c230f )
by Mathieu
02:46 queued 40s
created

LinkLog::link()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Charcoal\Email\Objects;
6
7
use DateTime;
8
use DateTimeInterface;
9
use Exception;
10
use InvalidArgumentException;
11
12
// From 'locomotivemtl/charcoal-core'
13
use Charcoal\Model\AbstractModel;
14
15
/**
16
 * Link (click) log
17
 */
18
class LinkLog extends AbstractModel
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: hasProperty, p, properties, property
Loading history...
19
{
20
    /**
21
     * @var string|null
22
     */
23
    private $link;
24
25
    /**
26
     * @var DateTimeInterface|null
27
     */
28
    private $ts;
29
30
    /**
31
     * @var string|null
32
     */
33
    private $ip;
34
35
    /**
36
     * @param string|null $linkId The link id.
37
     * @return self
38
     */
39
    public function setLink(?string $linkId)
40
    {
41
        $this->link = $linkId;
42
        return $this;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function link(): ?string
49
    {
50
        return $this->link;
51
    }
52
53
    /**
54
     * @param  null|string|DateTimeInterface $ts The "timestamp" datetime value.
55
     * @throws InvalidArgumentException If the timestamp is not a valid datetime value.
56
     * @return self
57
     */
58
    public function setTs($ts)
59
    {
60
        if ($ts === null) {
61
            $this->ts = null;
62
            return $this;
63
        }
64
65
        if (is_string($ts)) {
66
            try {
67
                $ts = new DateTime($ts);
68
            } catch (Exception $e) {
69
                throw new InvalidArgumentException($e->getMessage());
70
            }
71
        }
72
73
        if (!($ts instanceof DateTimeInterface)) {
74
            throw new InvalidArgumentException(
75
                'Invalid "Send Date" value. Must be a date/time string or a DateTime object.'
76
            );
77
        }
78
79
        $this->ts = $ts;
80
        return $this;
81
    }
82
83
    /**
84
     * @return null|DateTimeInterface
85
     */
86
    public function ts()
87
    {
88
        return $this->ts;
89
    }
90
91
    /**
92
     * @param string|null $ip The IP address.
93
     * @return self
94
     */
95
    public function setIp(?string $ip)
96
    {
97
        $this->ip = $ip;
98
        return $this;
99
    }
100
101
    /**
102
     * @return string|null
103
     */
104
    public function ip(): ?string
105
    {
106
        return $this->ip;
107
    }
108
}
109