setFullAmount($fullAmount); $this->setCashAmount($cashAmount); $this->setCashAmountsByCurrency($cashAmountsByCurrency); $this->setPaymentTypes($paymentTypes); } /** * @param $apiResult * * @return static */ public static function fromApiResult(object $apiResult): self { return new self( (float)$apiResult->full_amount, (float)$apiResult->cash_amount, CashAmountByCurrencyCollection::fromApiResult($apiResult->cash_amounts_by_currency), CashPointClosingPaymentTypeCollection::fromApiResult($apiResult->payment_types) ); } /** * @param array $dbState * * @return static */ public static function fromDbState(array $dbState): self { return new self( (float)$dbState['full_amount'], (float)$dbState['cash_amount'], CashAmountByCurrencyCollection::fromDbState($dbState['cash_amounts_by_currency']), CashPointClosingPaymentTypeCollection::fromDbState($dbState['payment_types']) ); } /** * @return array */ public function toArray(): array { return [ 'full_amount' => $this->getFullAmount(), 'cash_amount' => $this->getCashAmount(), 'cash_amounts_by_currency' => $this->getCashAmountsByCurrency()->toArray(), 'payment_types' => $this->getPaymentTypes()->toArray(), ]; } /** * @return float */ public function getFullAmount(): float { return $this->fullAmount; } /** * @param float $fullAmount */ public function setFullAmount(float $fullAmount): void { $this->fullAmount = (float)number_format($fullAmount, 2, '.', ''); } /** * @return mixed */ public function getCashAmount() { return $this->cashAmount; } /** * @param float $cashAmount */ public function setCashAmount(float $cashAmount): void { $this->cashAmount = (float)number_format($cashAmount, 2, '.', ''); } /** * @return CashAmountByCurrencyCollection */ public function getCashAmountsByCurrency(): CashAmountByCurrencyCollection { return CashAmountByCurrencyCollection::fromDbState($this->cashAmountsByCurrency->toArray()); } /** * @param CashAmountByCurrencyCollection $cashAmountsByCurrency */ public function setCashAmountsByCurrency(CashAmountByCurrencyCollection $cashAmountsByCurrency): void { $this->cashAmountsByCurrency = CashAmountByCurrencyCollection::fromDbState($cashAmountsByCurrency->toArray()); } /** * @return CashPointClosingPaymentTypeCollection */ public function getPaymentTypes(): CashPointClosingPaymentTypeCollection { return CashPointClosingPaymentTypeCollection::fromDbState($this->paymentTypes->toArray()); } /** * @param CashPointClosingPaymentTypeCollection $paymentTypes */ public function setPaymentTypes(CashPointClosingPaymentTypeCollection $paymentTypes): void { $this->paymentTypes = CashPointClosingPaymentTypeCollection::fromDbState($paymentTypes->toArray()); } }