commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
CustomModel.php
1<?php
2
3declare(strict_types=1);
10
17use stdClass;
18
22final class CustomModel extends JsonObjectModel implements Custom
23{
28 protected $type;
29
34 protected $fields;
35
36
40 public function __construct(
41 ?TypeKeyReference $type = null,
43 ) {
44 $this->type = $type;
45 $this->fields = $fields;
46 }
47
54 public function getType()
55 {
56 if (is_null($this->type)) {
58 $data = $this->raw(self::FIELD_TYPE);
59 if (is_null($data)) {
60 return null;
61 }
62
63 $this->type = TypeKeyReferenceModel::of($data);
64 }
65
66 return $this->type;
67 }
68
75 public function getFields()
76 {
77 if (is_null($this->fields)) {
79 $data = $this->raw(self::FIELD_FIELDS);
80 if (is_null($data)) {
81 return null;
82 }
83
84 $this->fields = FieldContainerModel::of($data);
85 }
86
87 return $this->fields;
88 }
89
90
94 public function setType(?TypeKeyReference $type): void
95 {
96 $this->type = $type;
97 }
98
102 public function setFields(?FieldContainer $fields): void
103 {
104 $this->fields = $fields;
105 }
106}
__construct(?TypeKeyReference $type=null, ?FieldContainer $fields=null)
static of($data=null)