shipment->getPackages() as $package) { Validator::checkIfNull($package->getWeight(), 'weight'); Validator::checkIfNull($package->getLength(), 'length'); Validator::checkIfNull($package->getHeight(), 'height'); Validator::checkIfNull($package->getWidth(), 'width'); } } public function __construct($options = []) { $this->rates = []; $this->isProduction = (bool) Arr::get($options, 'prod', false); $this->shipment = Arr::get($options, 'shipment'); } public function setRequestAdapter(RateRequest\Adapter $rateRequest) { $this->rateRequest = $rateRequest; } public function setShipment($shipment) { $this->shipment = $shipment; } public function getShipment() { return $this->shipment; } public function setIsProduction($isProduction): void { $this->isProduction = $isProduction; } public function getIsProduction(): bool { return $this->isProduction; } /** * @return Quote[] */ public function getRates(): array { $this ->validate() ->prepare() ->execute() ->process() ->sortByCost(); return array_values($this->rates); } protected function sortByCost(): void { uasort($this->rates, static function (Quote $a, Quote $b) { return ($a->getCost() > $b->getCost()); }); } }