Test Failed
Pull Request — master (#228)
by Guilherme
03:49
created

UpdateStatusEvent::getSentAt()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace LoginCidadao\PhoneVerificationBundle\Event;
12
13
use LoginCidadao\PhoneVerificationBundle\Model\SmsStatusInterface;
14
use Symfony\Component\EventDispatcher\Event;
15
16
class UpdateStatusEvent extends Event
17
{
18
    /** @var string */
19
    private $transactionId;
20
21
    /** @var SmsStatusInterface */
22
    private $deliveryStatus;
23
24
    /** @var boolean */
25
    private $updated = false;
26
27
    /**
28
     * UpdateStatusEvent constructor.
29
     * @param string $transactionId
30
     */
31
    public function __construct($transactionId)
32
    {
33
        $this->transactionId = $transactionId;
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getTransactionId()
40
    {
41
        return $this->transactionId;
42
    }
43
44
    /**
45
     * @return \DateTime
46
     */
47
    public function getSentAt()
48
    {
49
        if (null !== $this->getDeliveryStatus()) {
50
            return $this->getDeliveryStatus()->getDateSent();
51
        } else {
52
            return null;
53
        }
54
    }
55
56
    /**
57
     * @return \DateTime
58
     */
59
    public function getDeliveredAt()
60
    {
61
        if (null !== $this->getDeliveryStatus()) {
62
            return $this->getDeliveryStatus()->getDateDelivered();
63
        } else {
64
            return null;
65
        }
66
    }
67
68
    /**
69
     * @return SmsStatusInterface
70
     */
71
    public function getDeliveryStatus()
72
    {
73
        return $this->deliveryStatus;
74
    }
75
76
    /**
77
     * @param SmsStatusInterface $deliveryStatus
78
     * @return UpdateStatusEvent
79
     */
80
    public function setDeliveryStatus($deliveryStatus)
81
    {
82
        $this->deliveryStatus = $deliveryStatus;
83
        $this->setUpdated();
84
85
        return $this;
86
    }
87
88
    /**
89
     * Checks if any data was fetched.
90
     *
91
     * @return bool
92
     */
93
    public function isUpdated()
94
    {
95
        return $this->updated;
96
    }
97
98
    /**
99
     * @param bool $updated
100
     * @return UpdateStatusEvent
101
     */
102
    private function setUpdated($updated = true)
103
    {
104
        $this->updated = $updated;
105
106
        return $this;
107
    }
108
}
109