commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
MoneyAttributeModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
17 use stdClass;
18 
22 final class MoneyAttributeModel extends JsonObjectModel implements MoneyAttribute
23 {
24  public const DISCRIMINATOR_VALUE = 'money';
29  protected $name;
30 
35  protected $type;
36 
41  protected $value;
42 
43 
47  public function __construct(
48  ?string $name = null,
49  ?TypedMoney $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 
101  public function getValue()
102  {
103  if (is_null($this->value)) {
105  $data = $this->raw(self::FIELD_VALUE);
106  if (is_null($data)) {
107  return null;
108  }
109  $className = TypedMoneyModel::resolveDiscriminatorClass($data);
110  $this->value = $className::of($data);
111  }
112 
113  return $this->value;
114  }
115 
116 
120  public function setName(?string $name): void
121  {
122  $this->name = $name;
123  }
124 
128  public function setValue(?TypedMoney $value): void
129  {
130  $this->value = $value;
131  }
132 }
__construct(?string $name=null, ?TypedMoney $value=null, ?string $type=null)