commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ApprovalFlowRejectionModel.php
1<?php
2
3declare(strict_types=1);
10
17use DateTimeImmutable;
18use stdClass;
19
24{
29 protected $rejecter;
30
35 protected $rejectedAt;
36
41 protected $reason;
42
43
47 public function __construct(
48 ?Associate $rejecter = null,
49 ?DateTimeImmutable $rejectedAt = null,
50 ?string $reason = null
51 ) {
52 $this->rejecter = $rejecter;
53 $this->rejectedAt = $rejectedAt;
54 $this->reason = $reason;
55 }
56
63 public function getRejecter()
64 {
65 if (is_null($this->rejecter)) {
67 $data = $this->raw(self::FIELD_REJECTER);
68 if (is_null($data)) {
69 return null;
70 }
71
72 $this->rejecter = AssociateModel::of($data);
73 }
74
75 return $this->rejecter;
76 }
77
84 public function getRejectedAt()
85 {
86 if (is_null($this->rejectedAt)) {
88 $data = $this->raw(self::FIELD_REJECTED_AT);
89 if (is_null($data)) {
90 return null;
91 }
92 $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data);
93 if (false === $data) {
94 return null;
95 }
96 $this->rejectedAt = $data;
97 }
98
99 return $this->rejectedAt;
100 }
101
108 public function getReason()
109 {
110 if (is_null($this->reason)) {
112 $data = $this->raw(self::FIELD_REASON);
113 if (is_null($data)) {
114 return null;
115 }
116 $this->reason = (string) $data;
117 }
118
119 return $this->reason;
120 }
121
122
126 public function setRejecter(?Associate $rejecter): void
127 {
128 $this->rejecter = $rejecter;
129 }
130
134 public function setRejectedAt(?DateTimeImmutable $rejectedAt): void
135 {
136 $this->rejectedAt = $rejectedAt;
137 }
138
142 public function setReason(?string $reason): void
143 {
144 $this->reason = $reason;
145 }
146
147
148 #[\ReturnTypeWillChange]
149 public function jsonSerialize()
150 {
151 $data = $this->toArray();
152 if (isset($data[ApprovalFlowRejection::FIELD_REJECTED_AT]) && $data[ApprovalFlowRejection::FIELD_REJECTED_AT] instanceof \DateTimeImmutable) {
153 $data[ApprovalFlowRejection::FIELD_REJECTED_AT] = $data[ApprovalFlowRejection::FIELD_REJECTED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c');
154 }
155 return (object) $data;
156 }
157}
__construct(?Associate $rejecter=null, ?DateTimeImmutable $rejectedAt=null, ?string $reason=null)