commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
MoneyModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
15 use stdClass;
16 
20 final class MoneyModel extends JsonObjectModel implements Money
21 {
22  public const DISCRIMINATOR_VALUE = 'centPrecision';
27  protected $type;
28 
33  protected $fractionDigits;
34 
39  protected $centAmount;
40 
45  protected $currencyCode;
46 
47 
51  public function __construct(
52  ?int $fractionDigits = null,
53  ?int $centAmount = null,
54  ?string $currencyCode = null,
55  ?string $type = null
56  ) {
57  $this->fractionDigits = $fractionDigits;
58  $this->centAmount = $centAmount;
59  $this->currencyCode = $currencyCode;
60  $this->type = $type ?? self::DISCRIMINATOR_VALUE;
61  }
62 
67  public function getType()
68  {
69  if (is_null($this->type)) {
71  $data = $this->raw(self::FIELD_TYPE);
72  if (is_null($data)) {
73  return null;
74  }
75  $this->type = (string) $data;
76  }
77 
78  return $this->type;
79  }
80 
85  public function getFractionDigits()
86  {
87  if (is_null($this->fractionDigits)) {
89  $data = $this->raw(self::FIELD_FRACTION_DIGITS);
90  if (is_null($data)) {
91  return null;
92  }
93  $this->fractionDigits = (int) $data;
94  }
95 
96  return $this->fractionDigits;
97  }
98 
103  public function getCentAmount()
104  {
105  if (is_null($this->centAmount)) {
107  $data = $this->raw(self::FIELD_CENT_AMOUNT);
108  if (is_null($data)) {
109  return null;
110  }
111  $this->centAmount = (int) $data;
112  }
113 
114  return $this->centAmount;
115  }
116 
123  public function getCurrencyCode()
124  {
125  if (is_null($this->currencyCode)) {
127  $data = $this->raw(self::FIELD_CURRENCY_CODE);
128  if (is_null($data)) {
129  return null;
130  }
131  $this->currencyCode = (string) $data;
132  }
133 
134  return $this->currencyCode;
135  }
136 
137 
141  public function setFractionDigits(?int $fractionDigits): void
142  {
143  $this->fractionDigits = $fractionDigits;
144  }
145 
149  public function setCentAmount(?int $centAmount): void
150  {
151  $this->centAmount = $centAmount;
152  }
153 
157  public function setCurrencyCode(?string $currencyCode): void
158  {
159  $this->currencyCode = $currencyCode;
160  }
161 }
__construct(?int $fractionDigits=null, ?int $centAmount=null, ?string $currencyCode=null, ?string $type=null)
Definition: MoneyModel.php:51