commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
MoneyFieldModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
17 use stdClass;
18 
22 final class MoneyFieldModel extends JsonObjectModel implements MoneyField
23 {
24  public const DISCRIMINATOR_VALUE = 'Money';
29  protected $type;
30 
35  protected $value;
36 
37 
41  public function __construct(
42  ?TypedMoney $value = null,
43  ?string $type = null
44  ) {
45  $this->value = $value;
46  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
47  }
48 
55  public function getType()
56  {
57  if (is_null($this->type)) {
59  $data = $this->raw(self::FIELD_TYPE);
60  if (is_null($data)) {
61  return null;
62  }
63  $this->type = (string) $data;
64  }
65 
66  return $this->type;
67  }
68 
73  public function getValue()
74  {
75  if (is_null($this->value)) {
77  $data = $this->raw(self::FIELD_VALUE);
78  if (is_null($data)) {
79  return null;
80  }
82  $this->value = $className::of($data);
83  }
84 
85  return $this->value;
86  }
87 
88 
92  public function setValue(?TypedMoney $value): void
93  {
94  $this->value = $value;
95  }
96 }
__construct(?TypedMoney $value=null, ?string $type=null)