commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
lib
commercetools-base
src
Base
BaseJsonObject.php
1
<?php
2
3
declare(strict_types=1);
10
namespace
Commercetools\Base
;
11
12
use stdClass;
13
17
abstract
class
BaseJsonObject
implements
JsonObject
18
{
20
private
$rawData;
21
26
final
public
static
function
of
($data =
null
)
27
{
28
if
(is_array($data)) {
29
return
self::fromArray
($data);
30
}
31
return
self::fromStdClass
($data);
32
}
33
38
final
public
static
function
fromStdClass
(stdClass $data =
null
)
39
{
40
$t =
new
static
();
41
$t->rawData = $data;
42
return
$t;
43
}
44
49
final
public
static
function
fromArray
(array $data = [])
50
{
51
return
self::fromStdClass
((
object
)$data);
52
}
53
57
final
protected
function
raw
(
string
$field)
58
{
59
if
(isset($this->rawData->$field)) {
64
return
$this->rawData->$field;
65
}
66
return
null
;
67
}
68
69
#[\ReturnTypeWillChange]
70
public
function
jsonSerialize
()
71
{
72
return
(
object
)$this->
toArray
();
73
}
74
78
final
protected
function
getRawDataArray
(): array
79
{
80
if
(is_null($this->rawData)) {
81
return
[];
82
}
83
return
get_object_vars($this->rawData);
84
}
85
89
abstract
protected
function
toArray
(): array;
90
}
Commercetools\Base\BaseJsonObject
Definition:
BaseJsonObject.php:18
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\BaseJsonObject\toArray
toArray()
Commercetools\Base\BaseJsonObject\getRawDataArray
getRawDataArray()
Definition:
BaseJsonObject.php:78
Commercetools\Base\BaseJsonObject\jsonSerialize
jsonSerialize()
Definition:
BaseJsonObject.php:70
Commercetools\Base\BaseJsonObject\fromStdClass
static fromStdClass(stdClass $data=null)
Definition:
BaseJsonObject.php:38
Commercetools\Base\BaseJsonObject\fromArray
static fromArray(array $data=[])
Definition:
BaseJsonObject.php:49
Commercetools\Base\JsonObject
Definition:
JsonObject.php:15
Commercetools\Base
Definition:
MapperArraySequence.php:10
Generated by
1.9.1