/**
  * @test
  */
 public function itShouldSetMissingValuesToNull()
 {
     $customer = Customer::fromArray([]);
     $this->assertNull($customer->merchantCustomerId());
     $this->assertNull($customer->emailAddress());
     $this->assertNull($customer->firstName());
     $this->assertNull($customer->lastName());
     $this->assertNull($customer->addressType());
     $this->assertNull($customer->address());
     $this->assertNull($customer->postalCode());
     $this->assertNull($customer->housenumber());
     $this->assertNull($customer->country());
     $this->assertNull($customer->phoneNumbers());
 }
Exemple #2
0
 /**
  * @param array $order
  * @return Order
  */
 public static function fromArray(array $order)
 {
     Guard::keyExists($order, 'transactions');
     Guard::keyExists($order, 'amount');
     Guard::keyExists($order, 'currency');
     return new static(Transactions::fromArray($order['transactions']), Amount::fromInteger($order['amount']), Currency::fromString($order['currency']), array_key_exists('description', $order) ? Description::fromString($order['description']) : null, array_key_exists('merchant_order_id', $order) ? MerchantOrderId::fromString($order['merchant_order_id']) : null, array_key_exists('return_url', $order) ? Url::fromString($order['return_url']) : null, array_key_exists('expiration_period', $order) ? new \DateInterval($order['expiration_period']) : null, array_key_exists('id', $order) ? Uuid::fromString($order['id']) : null, array_key_exists('project_id', $order) ? Uuid::fromString($order['project_id']) : null, array_key_exists('created', $order) ? new Carbon($order['created']) : null, array_key_exists('modified', $order) ? new Carbon($order['modified']) : null, array_key_exists('completed', $order) ? new Carbon($order['completed']) : null, array_key_exists('status', $order) ? Status::fromString($order['status']) : null, array_key_exists('customer', $order) && $order['customer'] !== null ? Customer::fromArray($order['customer']) : null, array_key_exists('extra', $order) && $order['extra'] !== null ? Extra::fromArray($order['extra']) : null, array_key_exists('webhook_url', $order) ? Url::fromString($order['webhook_url']) : null);
 }