コード例 #1
0
 /**
  * @param array $transaction
  * @return Transaction
  */
 public static function fromArray(array $transaction)
 {
     Guard::keyExists($transaction, 'payment_method');
     $paymentMethod = PaymentMethod::fromString($transaction['payment_method']);
     return new static($paymentMethod, PaymentMethodDetails\PaymentMethodDetailsFactory::createFromArray($paymentMethod, array_key_exists('payment_method_details', $transaction) ? $transaction['payment_method_details'] : []), array_key_exists('id', $transaction) ? Uuid::fromString($transaction['id']) : null, array_key_exists('created', $transaction) ? new Carbon($transaction['created']) : null, array_key_exists('modified', $transaction) ? new Carbon($transaction['modified']) : null, array_key_exists('completed', $transaction) ? new Carbon($transaction['completed']) : null, array_key_exists('status', $transaction) ? TransactionStatus::fromString($transaction['status']) : null, array_key_exists('reason', $transaction) ? Reason::fromString($transaction['reason']) : null, array_key_exists('currency', $transaction) ? Currency::fromString($transaction['currency']) : null, array_key_exists('amount', $transaction) ? TransactionAmount::fromInteger($transaction['amount']) : null, array_key_exists('expiration_period', $transaction) ? new \DateInterval($transaction['expiration_period']) : null, array_key_exists('description', $transaction) ? TransactionDescription::fromString($transaction['description']) : null, array_key_exists('balance', $transaction) ? Balance::fromString($transaction['balance']) : null, array_key_exists('payment_url', $transaction) ? Url::fromString($transaction['payment_url']) : null);
 }
コード例 #2
0
ファイル: UrlTest.php プロジェクト: duronrulez/ginger-php
 /**
  * @test
  */
 public function itShouldGuardAgainstAnInvalidUrl()
 {
     $this->setExpectedException('Assert\\InvalidArgumentException');
     Url::fromString('very-invalid');
 }