From 00a7de74944dc15eaebab4236475ad3a55eb55fb Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Thu, 4 Apr 2024 06:35:22 +1300 Subject: [PATCH] fix: define properties (#74) --- src/ShippingPackage.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/ShippingPackage.php b/src/ShippingPackage.php index 15f95a7..ab3e36f 100644 --- a/src/ShippingPackage.php +++ b/src/ShippingPackage.php @@ -28,6 +28,12 @@ class ShippingPackage protected $quantity; + protected $shape; + + protected $weightunit; + + protected $widthunit; + protected $defaultdimensions = [ 'height' => 0, 'width' => 0, @@ -78,6 +84,7 @@ public function __construct($weight = 0, $dimensions = [], $options = []) $this->defaultdimensions, ['value' => null, 'quantity' => null] ); + foreach ($zerochecks as $dimension => $value) { if ($this->$dimension < 0) { $this->$dimension = 0; @@ -98,9 +105,11 @@ public function toArray() "currency" => $this->currency, "quantity" => $this->quantity ]; + return array_filter($data); } + public function __toString() { $out = ""; @@ -147,4 +156,29 @@ public function quantity() { return $this->quantity; } + + public function shape() + { + return $this->shape; + } + + public function weightunit() + { + return $this->weightunit; + } + + public function widthunit() + { + return $this->widthunit; + } + + public function diameter() + { + return $this->diameter; + } + + public function currency() + { + return $this->currency; + } }