commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
FieldDefinitionModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
17 use stdClass;
18 
23 {
28  protected $type;
29 
34  protected $name;
35 
40  protected $label;
41 
46  protected $required;
47 
52  protected $inputHint;
53 
54 
58  public function __construct(
59  ?FieldType $type = null,
60  ?string $name = null,
61  ?LocalizedString $label = null,
62  ?bool $required = null,
63  ?string $inputHint = null
64  ) {
65  $this->type = $type;
66  $this->name = $name;
67  $this->label = $label;
68  $this->required = $required;
69  $this->inputHint = $inputHint;
70  }
71 
78  public function getType()
79  {
80  if (is_null($this->type)) {
82  $data = $this->raw(self::FIELD_TYPE);
83  if (is_null($data)) {
84  return null;
85  }
87  $this->type = $className::of($data);
88  }
89 
90  return $this->type;
91  }
92 
99  public function getName()
100  {
101  if (is_null($this->name)) {
103  $data = $this->raw(self::FIELD_NAME);
104  if (is_null($data)) {
105  return null;
106  }
107  $this->name = (string) $data;
108  }
109 
110  return $this->name;
111  }
112 
119  public function getLabel()
120  {
121  if (is_null($this->label)) {
123  $data = $this->raw(self::FIELD_LABEL);
124  if (is_null($data)) {
125  return null;
126  }
127 
128  $this->label = LocalizedStringModel::of($data);
129  }
130 
131  return $this->label;
132  }
133 
140  public function getRequired()
141  {
142  if (is_null($this->required)) {
144  $data = $this->raw(self::FIELD_REQUIRED);
145  if (is_null($data)) {
146  return null;
147  }
148  $this->required = (bool) $data;
149  }
150 
151  return $this->required;
152  }
153 
160  public function getInputHint()
161  {
162  if (is_null($this->inputHint)) {
164  $data = $this->raw(self::FIELD_INPUT_HINT);
165  if (is_null($data)) {
166  return null;
167  }
168  $this->inputHint = (string) $data;
169  }
170 
171  return $this->inputHint;
172  }
173 
174 
178  public function setType(?FieldType $type): void
179  {
180  $this->type = $type;
181  }
182 
186  public function setName(?string $name): void
187  {
188  $this->name = $name;
189  }
190 
194  public function setLabel(?LocalizedString $label): void
195  {
196  $this->label = $label;
197  }
198 
202  public function setRequired(?bool $required): void
203  {
204  $this->required = $required;
205  }
206 
210  public function setInputHint(?string $inputHint): void
211  {
212  $this->inputHint = $inputHint;
213  }
214 }
static of($data=null)
Definition: MapperMap.php:45
__construct(?FieldType $type=null, ?string $name=null, ?LocalizedString $label=null, ?bool $required=null, ?string $inputHint=null)