Completed
Pull Request — master (#228)
by Guilherme
04:22
created

UpdateStatusEvent   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 91
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getSentAt() 0 6 2
A setDeliveryStatus() 0 6 1
A getTransactionId() 0 3 1
A getDeliveredAt() 0 6 2
A getDeliveryStatus() 0 3 1
A __construct() 0 3 1
A setUpdated() 0 5 1
A isUpdated() 0 3 1
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 6
    public function __construct($transactionId)
32
    {
33 6
        $this->transactionId = $transactionId;
34 6
    }
35
36
    /**
37
     * @return string
38
     */
39 1
    public function getTransactionId()
40
    {
41 1
        return $this->transactionId;
42
    }
43
44
    /**
45
     * @return \DateTime
46
     */
47 2
    public function getSentAt()
48
    {
49 2
        if (null !== $this->getDeliveryStatus()) {
50 2
            return $this->getDeliveryStatus()->getDateSent();
51
        } else {
52 1
            return null;
53
        }
54
    }
55
56
    /**
57
     * @return \DateTime
58
     */
59 2
    public function getDeliveredAt()
60
    {
61 2
        if (null !== $this->getDeliveryStatus()) {
62 2
            return $this->getDeliveryStatus()->getDateDelivered();
63
        } else {
64 1
            return null;
65
        }
66
    }
67
68
    /**
69
     * @return SmsStatusInterface
70
     */
71 3
    public function getDeliveryStatus()
72
    {
73 3
        return $this->deliveryStatus;
74
    }
75
76
    /**
77
     * @param SmsStatusInterface $deliveryStatus
78
     * @return UpdateStatusEvent
79
     */
80 3
    public function setDeliveryStatus($deliveryStatus)
81
    {
82 3
        $this->deliveryStatus = $deliveryStatus;
83 3
        $this->setUpdated();
84
85 3
        return $this;
86
    }
87
88
    /**
89
     * Checks if any data was fetched.
90
     *
91
     * @return bool
92
     */
93 5
    public function isUpdated()
94
    {
95 5
        return $this->updated;
96
    }
97
98
    /**
99
     * @param bool $updated
100
     * @return UpdateStatusEvent
101
     */
102 3
    private function setUpdated($updated = true)
103
    {
104 3
        $this->updated = $updated;
105
106 3
        return $this;
107
    }
108
}
109