commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
ReferenceAttributeModel.php
1<?php
2
3declare(strict_types=1);
10
17use stdClass;
18
23{
24 public const DISCRIMINATOR_VALUE = 'reference';
29 protected $name;
30
35 protected $type;
36
41 protected $value;
42
43
47 public function __construct(
48 ?string $name = null,
49 ?KeyReference $value = null,
50 ?string $type = null
51 ) {
52 $this->name = $name;
53 $this->value = $value;
54 $this->type = $type ?? self::DISCRIMINATOR_VALUE;
55 }
56
65 public function getName()
66 {
67 if (is_null($this->name)) {
69 $data = $this->raw(self::FIELD_NAME);
70 if (is_null($data)) {
71 return null;
72 }
73 $this->name = (string) $data;
74 }
75
76 return $this->name;
77 }
78
83 public function getType()
84 {
85 if (is_null($this->type)) {
87 $data = $this->raw(self::FIELD_TYPE);
88 if (is_null($data)) {
89 return null;
90 }
91 $this->type = (string) $data;
92 }
93
94 return $this->type;
95 }
96
103 public function getValue()
104 {
105 if (is_null($this->value)) {
107 $data = $this->raw(self::FIELD_VALUE);
108 if (is_null($data)) {
109 return null;
110 }
111 $className = KeyReferenceModel::resolveDiscriminatorClass($data);
112 $this->value = $className::of($data);
113 }
114
115 return $this->value;
116 }
117
118
122 public function setName(?string $name): void
123 {
124 $this->name = $name;
125 }
126
130 public function setValue(?KeyReference $value): void
131 {
132 $this->value = $value;
133 }
134}
__construct(?string $name=null, ?KeyReference $value=null, ?string $type=null)