commercetools-sdk-php-v2  master
The platform, import-api and ml-api PHP sdks generated from our api reference.
TaxPortionModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
17 use stdClass;
18 
22 final class TaxPortionModel extends JsonObjectModel implements TaxPortion
23 {
28  protected $name;
29 
34  protected $rate;
35 
40  protected $amount;
41 
42 
46  public function __construct(
47  ?string $name = null,
48  ?float $rate = null,
49  ?TypedMoney $amount = null
50  ) {
51  $this->name = $name;
52  $this->rate = $rate;
53  $this->amount = $amount;
54  }
55 
60  public function getName()
61  {
62  if (is_null($this->name)) {
64  $data = $this->raw(self::FIELD_NAME);
65  if (is_null($data)) {
66  return null;
67  }
68  $this->name = (string) $data;
69  }
70 
71  return $this->name;
72  }
73 
78  public function getRate()
79  {
80  if (is_null($this->rate)) {
82  $data = $this->raw(self::FIELD_RATE);
83  if (is_null($data)) {
84  return null;
85  }
86  $this->rate = (float) $data;
87  }
88 
89  return $this->rate;
90  }
91 
96  public function getAmount()
97  {
98  if (is_null($this->amount)) {
100  $data = $this->raw(self::FIELD_AMOUNT);
101  if (is_null($data)) {
102  return null;
103  }
104  $className = TypedMoneyModel::resolveDiscriminatorClass($data);
105  $this->amount = $className::of($data);
106  }
107 
108  return $this->amount;
109  }
110 
111 
115  public function setName(?string $name): void
116  {
117  $this->name = $name;
118  }
119 
123  public function setRate(?float $rate): void
124  {
125  $this->rate = $rate;
126  }
127 
131  public function setAmount(?TypedMoney $amount): void
132  {
133  $this->amount = $amount;
134  }
135 }
__construct(?string $name=null, ?float $rate=null, ?TypedMoney $amount=null)