factory() публичный статический Метод

factory method: returns an instance of Customer to the requesting method, with populated properties
public static factory ( array $attributes ) : Customer
$attributes array
Результат Customer
Пример #1
0
 public function testGet_givesErrorIfInvalidProperty()
 {
     $this->setExpectedException('PHPUnit_Framework_Error', 'Undefined property on Braintree\\Customer: foo');
     $c = Braintree\Customer::factory([]);
     $c->foo;
 }
Пример #2
0
 /**
  * generic method for validating incoming gateway responses
  *
  * creates a new Customer object and encapsulates
  * it inside a Result\Successful object, or
  * encapsulates a Errors object inside a Result\Error
  * alternatively, throws an Unexpected exception if the response is invalid.
  *
  * @ignore
  * @param array $response gateway response values
  * @return Result\Successful|Result\Error
  * @throws Exception\Unexpected
  */
 private function _verifyGatewayResponse($response)
 {
     if (isset($response['customer'])) {
         // return a populated instance of Customer
         return new Result\Successful(Customer::factory($response['customer']));
     } else {
         if (isset($response['apiErrorResponse'])) {
             return new Result\Error($response['apiErrorResponse']);
         } else {
             throw new Exception\Unexpected("Expected customer or apiErrorResponse");
         }
     }
 }