You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ShippingRates/src/Package.php

106 lines
1.9 KiB
PHP

<?php
namespace pdt256\Shipping;
class Package {
protected $pounds;
protected $ounces;
protected $width;
protected $length;
protected $height;
public function getWeight() {
$weight = 0;
if (!empty($this->getPounds())) {
$weight += $this->getPounds();
}
if (!empty($this->getOunces())) {
$weight += ($this->getOunces() / 16);
}
if ($weight == 0) {
return null;
}
return $weight;
}
public function getPounds() {
return $this->pounds ?? 0;
}
public function getOunces() {
return $this->ounces ?? 0;
}
public function setWeight($pounds) {
return $this->setPounds($pounds)->setOunces(0);
}
/**
* @param mixed $pounds
* @return $this
*/
public function setPounds($pounds) {
$this->pounds = $pounds;
return $this;
}
/**
* @param mixed $ounces
* @return $this
*/
public function setOunces($ounces) {
$this->ounces = $ounces;
return $this;
}
/**
* @return mixed
*/
public function getWidth() {
return $this->width;
}
/**
* @param mixed $width
* @return $this
*/
public function setWidth($width) {
$this->width = $width;
return $this;
}
/**
* @return mixed
*/
public function getLength() {
return $this->length;
}
/**
* @param mixed $length
* @return $this
*/
public function setLength($length) {
$this->length = $length;
return $this;
}
/**
* @return mixed
*/
public function getHeight() {
return $this->height;
}
/**
* @param mixed $height
* @return $this
*/
public function setHeight($height) {
$this->height = $height;
return $this;
}
}