commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
AssetModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
17 use stdClass;
18 
22 final class AssetModel extends JsonObjectModel implements Asset
23 {
28  protected $key;
29 
34  protected $sources;
35 
40  protected $name;
41 
46  protected $description;
47 
52  protected $tags;
53 
58  protected $custom;
59 
60 
64  public function __construct(
65  ?string $key = null,
67  ?LocalizedString $name = null,
69  ?array $tags = null,
70  ?Custom $custom = null
71  ) {
72  $this->key = $key;
73  $this->sources = $sources;
74  $this->name = $name;
75  $this->description = $description;
76  $this->tags = $tags;
77  $this->custom = $custom;
78  }
79 
87  public function getKey()
88  {
89  if (is_null($this->key)) {
91  $data = $this->raw(self::FIELD_KEY);
92  if (is_null($data)) {
93  return null;
94  }
95  $this->key = (string) $data;
96  }
97 
98  return $this->key;
99  }
100 
105  public function getSources()
106  {
107  if (is_null($this->sources)) {
109  $data = $this->raw(self::FIELD_SOURCES);
110  if (is_null($data)) {
111  return null;
112  }
113  $this->sources = AssetSourceCollection::fromArray($data);
114  }
115 
116  return $this->sources;
117  }
118 
130  public function getName()
131  {
132  if (is_null($this->name)) {
134  $data = $this->raw(self::FIELD_NAME);
135  if (is_null($data)) {
136  return null;
137  }
138 
139  $this->name = LocalizedStringModel::of($data);
140  }
141 
142  return $this->name;
143  }
144 
156  public function getDescription()
157  {
158  if (is_null($this->description)) {
160  $data = $this->raw(self::FIELD_DESCRIPTION);
161  if (is_null($data)) {
162  return null;
163  }
164 
165  $this->description = LocalizedStringModel::of($data);
166  }
167 
168  return $this->description;
169  }
170 
175  public function getTags()
176  {
177  if (is_null($this->tags)) {
179  $data = $this->raw(self::FIELD_TAGS);
180  if (is_null($data)) {
181  return null;
182  }
183  $this->tags = $data;
184  }
185 
186  return $this->tags;
187  }
188 
195  public function getCustom()
196  {
197  if (is_null($this->custom)) {
199  $data = $this->raw(self::FIELD_CUSTOM);
200  if (is_null($data)) {
201  return null;
202  }
203 
204  $this->custom = CustomModel::of($data);
205  }
206 
207  return $this->custom;
208  }
209 
210 
214  public function setKey(?string $key): void
215  {
216  $this->key = $key;
217  }
218 
222  public function setSources(?AssetSourceCollection $sources): void
223  {
224  $this->sources = $sources;
225  }
226 
230  public function setName(?LocalizedString $name): void
231  {
232  $this->name = $name;
233  }
234 
239  {
240  $this->description = $description;
241  }
242 
246  public function setTags(?array $tags): void
247  {
248  $this->tags = $tags;
249  }
250 
254  public function setCustom(?Custom $custom): void
255  {
256  $this->custom = $custom;
257  }
258 }
static of($data=null)
Definition: MapperMap.php:45
__construct(?string $key=null, ?AssetSourceCollection $sources=null, ?LocalizedString $name=null, ?LocalizedString $description=null, ?array $tags=null, ?Custom $custom=null)
Definition: AssetModel.php:64
setSources(?AssetSourceCollection $sources)
Definition: AssetModel.php:222
setDescription(?LocalizedString $description)
Definition: AssetModel.php:238