/** * @param array $data * @param array|TravelInfo $travelInfo Keys:passengers|origin|destination * @return TravelCheckout */ public function createCheckout(array $data, $travelInfo) { if (!$travelInfo instanceof TravelInfo) { if (!is_array($travelInfo)) { throw new \InvalidArgumentException('Travel info not is array type'); } $travelInfo = $this->createInfoFromArray($travelInfo); } $dataFacade = new DataFacade(); $checkoutData = $dataFacade->ensureInstances($data); $checkout = new TravelCheckout($checkoutData); $checkout->setInfo($travelInfo); return $checkout; }
/** * @param array $data * @param array|PhoneInterface $phone Keys:areaCode|countryCode|number * @return TravelCheckout */ public function createCellPhoneChargerCheckout(array $data, $phone) { if (!$phone instanceof PhoneInterface) { $phone = Phone::factory($phone); } $dataFacade = new DataFacade(); $checkoutData = $dataFacade->ensureInstances($data); $checkout = new CellphoneChargerCheckout($checkoutData); $checkout->setPhone($phone); return $checkout; }