commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
src
Api
Models
Product
CustomFieldAccessor.php
1
<?php
2
3
4
namespace
Commercetools\Api\Models\Product
;
5
6
use
Commercetools\Api\Models\Common\LocalizedString
;
7
use
Commercetools\Api\Models\Common\LocalizedStringCollection
;
8
use
Commercetools\Api\Models\Common\LocalizedStringModel
;
9
use
Commercetools\Api\Models\Common\Money
;
10
use
Commercetools\Api\Models\Common\MoneyCollection
;
11
use
Commercetools\Api\Models\Common\MoneyModel
;
12
use
Commercetools\Api\Models\Common\Reference
;
13
use
Commercetools\Api\Models\Common\ReferenceModel
;
14
use
Commercetools\Api\Models\ProductType\AttributeLocalizedEnumValue
;
15
use
Commercetools\Api\Models\ProductType\AttributeLocalizedEnumValueCollection
;
16
use
Commercetools\Api\Models\ProductType\AttributeLocalizedEnumValueModel
;
17
use
Commercetools\Api\Models\ProductType\AttributePlainEnumValue
;
18
use
Commercetools\Api\Models\ProductType\AttributePlainEnumValueCollection
;
19
use
Commercetools\Api\Models\ProductType\AttributePlainEnumValueModel
;
20
use
Commercetools\Api\Models\Type\CustomFieldEnumValue
;
21
use
Commercetools\Api\Models\Type\CustomFieldEnumValueCollection
;
22
use
Commercetools\Api\Models\Type\CustomFieldEnumValueModel
;
23
use
Commercetools\Api\Models\Type\CustomFieldLocalizedEnumValue
;
24
use
Commercetools\Api\Models\Type\CustomFieldLocalizedEnumValueCollection
;
25
use
Commercetools\Api\Models\Type\CustomFieldLocalizedEnumValueModel
;
26
use
Commercetools\Base\DateTimeImmutableCollection
;
27
use
Commercetools\Base\MapperFactory
;
28
use DateTimeImmutable;
29
use stdClass;
30
31
class
CustomFieldAccessor
32
{
36
private
$value;
37
41
private
function
__construct($value)
42
{
43
$this->value = $value;
44
}
45
50
public
function
getValue
()
51
{
55
$value = $this->value;
56
return
$value;
57
}
58
62
public
static
function
of
()
63
{
64
return
function
($value):
CustomFieldAccessor
{
65
return
new
self
($value);
66
};
67
}
68
69
public
function
getValueAsEnum
():
CustomFieldEnumValue
70
{
74
$value = $this->value;
75
return
CustomFieldEnumValueModel::of
($value);
76
}
77
78
public
function
getValueAsLocalizedEnum
():
CustomFieldLocalizedEnumValue
79
{
83
$value = $this->value;
84
return
CustomFieldLocalizedEnumValueModel::of
($value);
85
}
86
87
public
function
getValueAsString
(): string
88
{
89
return
(
string
)$this->value;
90
}
91
92
public
function
getValueAsInt
(): int
93
{
94
return
(
int
)$this->value;
95
}
96
97
public
function
getValueAsFloat
(): float
98
{
99
return
(
float
)$this->value;
100
}
101
102
public
function
getValueAsBool
(): bool
103
{
104
return
(
bool
)$this->value;
105
}
106
107
public
function
getValueAsDateTime
(): ?DateTimeImmutable
108
{
109
$value = DateTimeImmutable::createFromFormat(
MapperFactory::DATETIME_FORMAT
, (
string
)$this->value);
110
return
$value ? $value :
null
;
111
}
112
113
public
function
getValueAsTime
(): ?DateTimeImmutable
114
{
115
$value = DateTimeImmutable::createFromFormat(
MapperFactory::TIME_FORMAT
, (
string
)$this->value);
116
return
$value ? $value :
null
;
117
}
118
119
public
function
getValueAsDate
(): ?DateTimeImmutable
120
{
121
$value = DateTimeImmutable::createFromFormat(
MapperFactory::DATE_FORMAT
, (
string
)$this->value);
122
return
$value ? $value :
null
;
123
}
124
125
public
function
getValueAsMoney
():
Money
126
{
130
$value = $this->value;
131
return
MoneyModel::of
($value);
132
}
133
134
public
function
getValueAsReference
():
Reference
135
{
139
$value = $this->value;
140
$refClass =
ReferenceModel::resolveDiscriminatorClass
($value);
141
return
$refClass::of($value);
142
}
143
144
public
function
getValueAsLocalizedString
():
LocalizedString
145
{
149
$value = $this->value;
150
return
LocalizedStringModel::of
($value);
151
}
152
153
public
function
getValueAsEnumSet
():
CustomFieldEnumValueCollection
154
{
158
$value = $this->value;
159
return
CustomFieldEnumValueCollection::fromArray
($value);
160
}
161
162
public
function
getValueAsLocalizedEnumSet
():
CustomFieldLocalizedEnumValueCollection
163
{
167
$value = $this->value;
168
return
CustomFieldLocalizedEnumValueCollection::fromArray
($value);
169
}
170
171
public
function
getValueAsStringSet
(): array
172
{
176
$value = $this->value;
177
return
$value;
178
}
179
180
public
function
getValueAsIntSet
(): array
181
{
185
$value = $this->value;
186
return
array_map(
function
($value) {
187
return
(
int
)$value;
188
}, $value);
189
}
190
191
public
function
getValueAsFloatSet
(): array
192
{
196
$value = $this->value;
197
return
array_map(
function
($value) {
198
return
(
float
)$value;
199
}, $value);
200
}
201
202
public
function
getValueAsBoolSet
(): array
203
{
207
$value = $this->value;
208
return
$value;
209
}
210
211
public
function
getValueAsDateTimeSet
():
DateTimeImmutableCollection
212
{
216
$value = $this->value;
217
return
DateTimeImmutableCollection::fromArray
($value);
218
}
219
220
public
function
getValueAsTimeSet
():
DateTimeImmutableCollection
221
{
225
$value = $this->value;
226
return
DateTimeImmutableCollection::fromArray
($value);
227
}
228
229
public
function
getValueAsDateSet
():
DateTimeImmutableCollection
230
{
234
$value = $this->value;
235
return
DateTimeImmutableCollection::fromArray
($value);
236
}
237
238
public
function
getValueAsMoneySet
():
MoneyCollection
239
{
243
$value = $this->value;
244
return
MoneyCollection::fromArray
($value);
245
}
246
247
public
function
getValueAsLocalizedStringSet
():
LocalizedStringCollection
248
{
252
$value = $this->value;
253
return
LocalizedStringCollection::fromArray
($value);
254
}
255
}
Commercetools\Api\Models\Common\LocalizedStringCollection
Definition:
LocalizedStringCollection.php:22
Commercetools\Api\Models\Common\LocalizedStringModel
Definition:
LocalizedStringModel.php:17
Commercetools\Api\Models\Common\MoneyCollection
Definition:
MoneyCollection.php:26
Commercetools\Api\Models\Common\MoneyModel
Definition:
MoneyModel.php:21
Commercetools\Api\Models\Common\ReferenceModel
Definition:
ReferenceModel.php:91
Commercetools\Api\Models\Common\ReferenceModel\resolveDiscriminatorClass
static resolveDiscriminatorClass($value)
Definition:
ReferenceModel.php:213
Commercetools\Api\Models\Product\CustomFieldAccessor
Definition:
CustomFieldAccessor.php:32
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsMoney
getValueAsMoney()
Definition:
CustomFieldAccessor.php:125
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsTimeSet
getValueAsTimeSet()
Definition:
CustomFieldAccessor.php:220
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsFloat
getValueAsFloat()
Definition:
CustomFieldAccessor.php:97
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsDateTimeSet
getValueAsDateTimeSet()
Definition:
CustomFieldAccessor.php:211
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsBool
getValueAsBool()
Definition:
CustomFieldAccessor.php:102
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsBoolSet
getValueAsBoolSet()
Definition:
CustomFieldAccessor.php:202
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsInt
getValueAsInt()
Definition:
CustomFieldAccessor.php:92
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsLocalizedStringSet
getValueAsLocalizedStringSet()
Definition:
CustomFieldAccessor.php:247
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsIntSet
getValueAsIntSet()
Definition:
CustomFieldAccessor.php:180
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsFloatSet
getValueAsFloatSet()
Definition:
CustomFieldAccessor.php:191
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsLocalizedEnumSet
getValueAsLocalizedEnumSet()
Definition:
CustomFieldAccessor.php:162
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsDateTime
getValueAsDateTime()
Definition:
CustomFieldAccessor.php:107
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsDateSet
getValueAsDateSet()
Definition:
CustomFieldAccessor.php:229
Commercetools\Api\Models\Product\CustomFieldAccessor\getValue
getValue()
Definition:
CustomFieldAccessor.php:50
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsEnum
getValueAsEnum()
Definition:
CustomFieldAccessor.php:69
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsMoneySet
getValueAsMoneySet()
Definition:
CustomFieldAccessor.php:238
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsLocalizedString
getValueAsLocalizedString()
Definition:
CustomFieldAccessor.php:144
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsTime
getValueAsTime()
Definition:
CustomFieldAccessor.php:113
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsLocalizedEnum
getValueAsLocalizedEnum()
Definition:
CustomFieldAccessor.php:78
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsDate
getValueAsDate()
Definition:
CustomFieldAccessor.php:119
Commercetools\Api\Models\Product\CustomFieldAccessor\of
static of()
Definition:
CustomFieldAccessor.php:62
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsReference
getValueAsReference()
Definition:
CustomFieldAccessor.php:134
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsString
getValueAsString()
Definition:
CustomFieldAccessor.php:87
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsEnumSet
getValueAsEnumSet()
Definition:
CustomFieldAccessor.php:153
Commercetools\Api\Models\Product\CustomFieldAccessor\getValueAsStringSet
getValueAsStringSet()
Definition:
CustomFieldAccessor.php:171
Commercetools\Api\Models\ProductType\AttributeLocalizedEnumValueCollection
Definition:
AttributeLocalizedEnumValueCollection.php:22
Commercetools\Api\Models\ProductType\AttributeLocalizedEnumValueModel
Definition:
AttributeLocalizedEnumValueModel.php:23
Commercetools\Api\Models\ProductType\AttributePlainEnumValueCollection
Definition:
AttributePlainEnumValueCollection.php:22
Commercetools\Api\Models\ProductType\AttributePlainEnumValueModel
Definition:
AttributePlainEnumValueModel.php:21
Commercetools\Api\Models\Type\CustomFieldEnumValueCollection
Definition:
CustomFieldEnumValueCollection.php:22
Commercetools\Api\Models\Type\CustomFieldEnumValueModel
Definition:
CustomFieldEnumValueModel.php:21
Commercetools\Api\Models\Type\CustomFieldLocalizedEnumValueCollection
Definition:
CustomFieldLocalizedEnumValueCollection.php:22
Commercetools\Api\Models\Type\CustomFieldLocalizedEnumValueModel
Definition:
CustomFieldLocalizedEnumValueModel.php:23
Commercetools\Base\BaseJsonObject\of
static of($data=null)
Definition:
BaseJsonObject.php:26
Commercetools\Base\DateTimeImmutableCollection
Definition:
DateTimeImmutableCollection.php:21
Commercetools\Base\MapperFactory
Definition:
MapperFactory.php:16
Commercetools\Base\MapperFactory\DATETIME_FORMAT
const DATETIME_FORMAT
Definition:
MapperFactory.php:19
Commercetools\Base\MapperFactory\TIME_FORMAT
const TIME_FORMAT
Definition:
MapperFactory.php:17
Commercetools\Base\MapperFactory\DATE_FORMAT
const DATE_FORMAT
Definition:
MapperFactory.php:18
Commercetools\Base\MapperMap\of
static of($data=null)
Definition:
MapperMap.php:45
Commercetools\Base\MapperScalarSequence\fromArray
static fromArray(array $data)
Definition:
MapperScalarSequence.php:56
Commercetools\Base\MapperSequence\fromArray
static fromArray(array $data)
Definition:
MapperSequence.php:56
Commercetools\Api\Models\Common\LocalizedString
Definition:
LocalizedString.php:14
Commercetools\Api\Models\Common\Money
Definition:
Money.php:15
Commercetools\Api\Models\Common\Reference
Definition:
Reference.php:50
Commercetools\Api\Models\ProductType\AttributeLocalizedEnumValue
Definition:
AttributeLocalizedEnumValue.php:16
Commercetools\Api\Models\ProductType\AttributePlainEnumValue
Definition:
AttributePlainEnumValue.php:15
Commercetools\Api\Models\Type\CustomFieldEnumValue
Definition:
CustomFieldEnumValue.php:15
Commercetools\Api\Models\Type\CustomFieldLocalizedEnumValue
Definition:
CustomFieldLocalizedEnumValue.php:16
Commercetools\Api\Models\Product
Definition:
AttributeAccessor.php:4
Generated by
1.9.1