SubscriptionResponseEntity::setActions()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
/**
4
 * PHP version 5.4 and 8
5
 *
6
 * @category  ResponseEntity
7
 * @package   Payever\ThirdParty
8
 * @author    payever GmbH <[email protected]>
9
 * @author    Hennadii.Shymanskyi <[email protected]>
10
 * @copyright 2017-2021 payever GmbH
11
 * @license   MIT <https://opensource.org/licenses/MIT>
12
 * @link      https://docs.payever.org/shopsystems/api/getting-started
13
 */
14
15
namespace Payever\ExternalIntegration\ThirdParty\Http\ResponseEntity;
16
17
use Payever\ExternalIntegration\Core\Http\ResponseEntity;
18
use Payever\ExternalIntegration\ThirdParty\Http\MessageEntity\SubscriptionActionEntity;
19
20
/**
21
 * @method string getId()
22
 * @method string getAuthorizationId()
23
 * @method string getIntegration()
24
 * @method bool getConnected()
25
 * @method \DateTime|false getCreatedAt()
26
 * @method \DateTime|false getUpdatedAt()
27
 * @method SubscriptionActionEntity[] getActions()
28
 */
29
class SubscriptionResponseEntity extends ResponseEntity
30
{
31
    /**
32
     * @deprecated use $authorizationId instead
33
     *
34
     * @var string
35
     */
36
    protected $externalId;
37
38
    /**
39
     * Field value must be saved by user for further use in sync-related requests
40
     *
41
     * @var string
42
     */
43
    protected $authorizationId;
44
45
    /** @var string */
46
    protected $integration;
47
48
    /** @var bool */
49
    protected $connected;
50
51
    /** @var \DateTime|bool */
52
    protected $createdAt;
53
54
    /** @var \DateTime|bool */
55
    protected $updatedAt;
56
57
    /** @var SubscriptionActionEntity[] */
58
    protected $actions;
59
60
    /**
61
     * @deprecated use getAuthorizationId() instead
62
     *
63
     * @return string
64
     */
65
    public function getExternalId()
66
    {
67
        return null === $this->externalId
0 ignored issues
show
Deprecated Code introduced by
The property Payever\ExternalIntegrat...onseEntity::$externalId has been deprecated: use $authorizationId instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

67
        return null === /** @scrutinizer ignore-deprecated */ $this->externalId

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
68
            ? $this->authorizationId
69
            : $this->externalId;
0 ignored issues
show
Deprecated Code introduced by
The property Payever\ExternalIntegrat...onseEntity::$externalId has been deprecated: use $authorizationId instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

69
            : /** @scrutinizer ignore-deprecated */ $this->externalId;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
70
    }
71
72
    /**
73
     * @param string $createdAt
74
     * @return self
75
     */
76
    public function setCreatedAt($createdAt)
77
    {
78
        if ($createdAt) {
79
            $this->createdAt = date_create($createdAt);
80
        }
81
82
        return $this;
83
    }
84
85
    /**
86
     * @param string $updatedAt
87
     * @return self
88
     */
89
    public function setUpdatedAt($updatedAt)
90
    {
91
        if ($updatedAt) {
92
            $this->updatedAt = date_create($updatedAt);
93
        }
94
95
        return $this;
96
    }
97
98
    /**
99
     * @param array $actions
100
     * @return static
101
     */
102
    public function setActions($actions)
103
    {
104
        foreach ($actions as $plainAction) {
105
            $this->actions[] = new SubscriptionActionEntity($plainAction);
106
        }
107
108
        return $this;
109
    }
110
111
    /**
112
     * @return array
113
     */
114
    public function getRequired()
115
    {
116
        return [
117
            'authorizationId',
118
            'connected',
119
        ];
120
    }
121
}
122