checkDescription($description); $this->checkAmount($description, $amount); $this->checkWeight($description, $weightInKg); $this->checkCountryOfOrigin($description, $countryOfOrigin); $this->checkTariffNumber($description, $customsTariffNumber); $this->checkValue($description, $value); $this->description = $description; $this->amount = $amount; $this->value = $value; $this->countryOfOrigin = $countryOfOrigin; $this->customsTariffNumber = $customsTariffNumber; $this->weightInKg = $weightInKg; } private function checkWeight($itemName, $weight){ if($weight <= 0){ throw new ContentsDataException("Falsches Gewicht von '{$itemName}'"); } } private function checkTariffNumber($itemName, $number){ if(empty($number)){ throw new ContentsDataException("Falsche Zolltarifnummer von '{$itemName}'"); } } private function checkCountryOfOrigin($itemName, $country){ if(strlen($country) !== 2){ throw new ContentsDataException("Herkunftsland von '{$itemName}' muss ISO-alpha-2 sein"); } } private function checkValue($itemName, $value){ if($value <= 0){ throw new ContentsDataException("Falscher wert von '{$itemName}': {$value}"); } } private function checkAmount($itemName, $amount){ if($amount <= 0){ throw new ContentsDataException("Falsche Menge bei position '{$itemName}': {$amount}"); } } private function checkDescription($description){ if(empty($description)){ throw new ContentsDataException('Fehlende Beschreibung in Positionen'); } } /** * @return float */ public function getWeightInKg() { return $this->weightInKg; } /** * @return int */ public function getAmount() { return $this->amount; } /** * @return string */ public function getDescription() { return $this->description; } /** * @return float */ public function getValue() { return $this->value; } /** * @return string */ public function getCountryOfOrigin() { return $this->countryOfOrigin; } /** * @return string */ public function getCustomsTariffNumber() { return $this->customsTariffNumber; } }