commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
Loading...
Searching...
No Matches
MoneyAttributeModel.php
1<?php
2
3declare(strict_types=1);
10
17use stdClass;
18
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
87 public function getType()
88 {
89 if (is_null($this->type)) {
91 $data = $this->raw(self::FIELD_TYPE);
92 if (is_null($data)) {
93 return null;
94 }
95 $this->type = (string) $data;
96 }
97
98 return $this->type;
99 }
100
107 public function getValue()
108 {
109 if (is_null($this->value)) {
111 $data = $this->raw(self::FIELD_VALUE);
112 if (is_null($data)) {
113 return null;
114 }
115 $className = TypedMoneyModel::resolveDiscriminatorClass($data);
116 $this->value = $className::of($data);
117 }
118
119 return $this->value;
120 }
121
122
126 public function setName(?string $name): void
127 {
128 $this->name = $name;
129 }
130
134 public function setValue(?TypedMoney $value): void
135 {
136 $this->value = $value;
137 }
138}
__construct(?string $name=null, ?TypedMoney $value=null, ?string $type=null)