protected function convertToModel($key, $params) { $paymentTypes = ['Boleto' => 'Braspag\\BoletoPayment', 'CreditCard' => 'Braspag\\CreditCardPayment', 'DebitCard' => 'Braspag\\DebitCardPayment', 'EletronicTransfer' => 'Braspag\\EletronicTransferPayment']; if ($key === 'payment') { return new $paymentTypes[$params['Type']]($params); } return parent::convertToModel($key, $params); }
protected function convertToModel($key, $params) { $property = []; if ($key === 'links') { $types = $this->getTypes(); foreach ($params as $link) { $property[] = new $types['link']($link); } return $property; } return parent::convertToModel($key, $params); }