commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ZoneRateModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
17 use stdClass;
18 
22 final class ZoneRateModel extends JsonObjectModel implements ZoneRate
23 {
28  protected $zone;
29 
34  protected $shippingRates;
35 
36 
40  public function __construct(
41  ?ZoneReference $zone = null,
43  ) {
44  $this->zone = $zone;
45  $this->shippingRates = $shippingRates;
46  }
47 
54  public function getZone()
55  {
56  if (is_null($this->zone)) {
58  $data = $this->raw(self::FIELD_ZONE);
59  if (is_null($data)) {
60  return null;
61  }
62 
63  $this->zone = ZoneReferenceModel::of($data);
64  }
65 
66  return $this->zone;
67  }
68 
75  public function getShippingRates()
76  {
77  if (is_null($this->shippingRates)) {
79  $data = $this->raw(self::FIELD_SHIPPING_RATES);
80  if (is_null($data)) {
81  return null;
82  }
83  $this->shippingRates = ShippingRateCollection::fromArray($data);
84  }
85 
86  return $this->shippingRates;
87  }
88 
89 
93  public function setZone(?ZoneReference $zone): void
94  {
95  $this->zone = $zone;
96  }
97 
102  {
103  $this->shippingRates = $shippingRates;
104  }
105 }
setShippingRates(?ShippingRateCollection $shippingRates)
__construct(?ZoneReference $zone=null, ?ShippingRateCollection $shippingRates=null)