Passed
Branch master (776013)
by payever
03:51
created

SubscriptionResponseEntity::setUpdatedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * PHP version 5.4 and 7
4
 *
5
 * @package   Payever\ThirdParty
6
 * @author    Hennadii.Shymanskyi <[email protected]>
7
 * @copyright 2017-2019 payever GmbH
8
 * @license   MIT <https://opensource.org/licenses/MIT>
9
 */
10
11
namespace Payever\ExternalIntegration\ThirdParty\Http\ResponseEntity;
12
13
use Payever\ExternalIntegration\Core\Http\ResponseEntity;
14
use Payever\ExternalIntegration\ThirdParty\Http\MessageEntity\SubscriptionActionEntity;
15
16
/**
17
 * Class SubscriptionResponseEntity
18
 *
19
 * PHP version 5.4 and 7
20
 *
21
 * @package   Payever\ThirdParty
22
 * @author    Hennadii.Shymanskyi <[email protected]>
23
 * @copyright 2017-2019 payever GmbH
24
 * @license   MIT <https://opensource.org/licenses/MIT>
25
 *
26
 * @method string getId()
27
 * @method string getExternalId()
28
 * @method bool getConnected()
29
 * @method \DateTime|false getCreatedAt()
30
 * @method \DateTime|false getUpdatedAt()
31
 * @method SubscriptionActionEntity[] getActions()
32
 */
33
class SubscriptionResponseEntity extends ResponseEntity
34
{
35
    /**
36
     * Field value must be saved by user for further use in sync-related requests
37
     *
38
     * @var string
39
     */
40
    protected $externalId;
41
42
    /** @var bool */
43
    protected $connected;
44
45
    /** @var \DateTime|bool */
46
    protected $createdAt;
47
48
    /** @var \DateTime|bool */
49
    protected $updatedAt;
50
51
    /** @var SubscriptionActionEntity[] */
52
    protected $actions;
53
54
    /**
55
     * @param string $createdAt
56
     */
57
    public function setCreatedAt($createdAt)
58
    {
59
        $this->createdAt = date_create($createdAt);
60
    }
61
62
    /**
63
     * @param string $updatedAt
64
     */
65
    public function setUpdatedAt($updatedAt)
66
    {
67
        $this->updatedAt = date_create($updatedAt);
68
    }
69
70
    /**
71
     * @param array $actions
72
     * @return static
73
     */
74
    public function setActions($actions)
75
    {
76
        foreach ($actions as $plainAction) {
77
            $this->actions[] = new SubscriptionActionEntity($plainAction);
78
        }
79
80
        return $this;
81
    }
82
83
    /**
84
     * @return array
85
     */
86
    public function getRequired()
87
    {
88
        return array(
89
            'externalId',
90
            'connected',
91
        );
92
    }
93
}
94