commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
CustomModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
17 use stdClass;
18 
22 final class CustomModel extends JsonObjectModel implements Custom
23 {
28  protected $type;
29 
34  protected $fields;
35 
36 
40  public function __construct(
41  ?TypeKeyReference $type = null,
42  ?FieldContainer $fields = 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 }
static of($data=null)
Definition: MapperMap.php:45
__construct(?TypeKeyReference $type=null, ?FieldContainer $fields=null)
Definition: CustomModel.php:40