commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
lib
commercetools-api
src
Models
ApprovalFlow
ApprovalFlowApprovalModel.php
1
<?php
2
3
declare(strict_types=1);
9
namespace
Commercetools\Api\Models\ApprovalFlow
;
10
11
use
Commercetools\Api\Models\BusinessUnit\Associate
;
12
use
Commercetools\Api\Models\BusinessUnit\AssociateModel
;
13
use
Commercetools\Base\DateTimeImmutableCollection
;
14
use
Commercetools\Base\JsonObject
;
15
use
Commercetools\Base\JsonObjectModel
;
16
use
Commercetools\Base\MapperFactory
;
17
use DateTimeImmutable;
18
use stdClass;
19
23
final
class
ApprovalFlowApprovalModel
extends
JsonObjectModel
implements
ApprovalFlowApproval
24
{
29
protected
$approver
;
30
35
protected
$approvedAt
;
36
37
41
public
function
__construct
(
42
?
Associate
$approver
=
null
,
43
?DateTimeImmutable
$approvedAt
=
null
44
) {
45
$this->approver =
$approver
;
46
$this->approvedAt =
$approvedAt
;
47
}
48
55
public
function
getApprover
()
56
{
57
if
(is_null($this->approver)) {
59
$data = $this->
raw
(self::FIELD_APPROVER);
60
if
(is_null($data)) {
61
return
null
;
62
}
63
64
$this->approver =
AssociateModel::of
($data);
65
}
66
67
return
$this->approver
;
68
}
69
76
public
function
getApprovedAt
()
77
{
78
if
(is_null($this->approvedAt)) {
80
$data = $this->
raw
(self::FIELD_APPROVED_AT);
81
if
(is_null($data)) {
82
return
null
;
83
}
84
$data = DateTimeImmutable::createFromFormat(
MapperFactory::DATETIME_FORMAT
, $data);
85
if
(
false
=== $data) {
86
return
null
;
87
}
88
$this->approvedAt = $data;
89
}
90
91
return
$this->approvedAt
;
92
}
93
94
98
public
function
setApprover
(?
Associate
$approver
): void
99
{
100
$this->approver =
$approver
;
101
}
102
106
public
function
setApprovedAt
(?DateTimeImmutable
$approvedAt
): void
107
{
108
$this->approvedAt =
$approvedAt
;
109
}
110
111
112
#[\ReturnTypeWillChange]
113
public
function
jsonSerialize
()
114
{
115
$data = $this->
toArray
();
116
if
(isset($data[
ApprovalFlowApproval::FIELD_APPROVED_AT
]) && $data[
ApprovalFlowApproval::FIELD_APPROVED_AT
] instanceof \DateTimeImmutable) {
117
$data[
ApprovalFlowApproval::FIELD_APPROVED_AT
] = $data[
ApprovalFlowApproval::FIELD_APPROVED_AT
]->setTimeZone(
new
\DateTimeZone(
'UTC'
))->format(
'c'
);
118
}
119
return
(
object
) $data;
120
}
121
}
Commercetools\Api\Models\ApprovalFlow\ApprovalFlowApprovalModel
Definition:
ApprovalFlowApprovalModel.php:24
Commercetools\Api\Models\ApprovalFlow\ApprovalFlowApprovalModel\getApprover
getApprover()
Definition:
ApprovalFlowApprovalModel.php:55
Commercetools\Api\Models\ApprovalFlow\ApprovalFlowApprovalModel\jsonSerialize
jsonSerialize()
Definition:
ApprovalFlowApprovalModel.php:113
Commercetools\Api\Models\ApprovalFlow\ApprovalFlowApprovalModel\__construct
__construct(?Associate $approver=null, ?DateTimeImmutable $approvedAt=null)
Definition:
ApprovalFlowApprovalModel.php:41
Commercetools\Api\Models\ApprovalFlow\ApprovalFlowApprovalModel\$approvedAt
$approvedAt
Definition:
ApprovalFlowApprovalModel.php:35
Commercetools\Api\Models\ApprovalFlow\ApprovalFlowApprovalModel\setApprover
setApprover(?Associate $approver)
Definition:
ApprovalFlowApprovalModel.php:98
Commercetools\Api\Models\ApprovalFlow\ApprovalFlowApprovalModel\$approver
$approver
Definition:
ApprovalFlowApprovalModel.php:29
Commercetools\Api\Models\ApprovalFlow\ApprovalFlowApprovalModel\getApprovedAt
getApprovedAt()
Definition:
ApprovalFlowApprovalModel.php:76
Commercetools\Api\Models\ApprovalFlow\ApprovalFlowApprovalModel\setApprovedAt
setApprovedAt(?DateTimeImmutable $approvedAt)
Definition:
ApprovalFlowApprovalModel.php:106
Commercetools\Api\Models\BusinessUnit\AssociateModel
Definition:
AssociateModel.php:23
Commercetools\Base\BaseJsonObject\raw
raw(string $field)
Definition:
BaseJsonObject.php:57
Commercetools\Base\BaseJsonObject\of
static of($data=null)
Definition:
BaseJsonObject.php:26
Commercetools\Base\DateTimeImmutableCollection
Definition:
DateTimeImmutableCollection.php:21
Commercetools\Base\JsonObjectModel
Definition:
JsonObjectModel.php:15
Commercetools\Base\JsonObjectModel\toArray
toArray()
Definition:
JsonObjectModel.php:32
Commercetools\Base\MapperFactory
Definition:
MapperFactory.php:16
Commercetools\Base\MapperFactory\DATETIME_FORMAT
const DATETIME_FORMAT
Definition:
MapperFactory.php:19
Commercetools\Api\Models\ApprovalFlow\ApprovalFlowApproval
Definition:
ApprovalFlowApproval.php:17
Commercetools\Api\Models\ApprovalFlow\ApprovalFlowApproval\FIELD_APPROVED_AT
const FIELD_APPROVED_AT
Definition:
ApprovalFlowApproval.php:19
Commercetools\Api\Models\BusinessUnit\Associate
Definition:
Associate.php:16
Commercetools\Base\JsonObject
Definition:
JsonObject.php:15
Commercetools\Api\Models\ApprovalFlow
Definition:
ApprovalFlow.php:9
Generated by
1.9.1