extractAttributeAsArray() public static method

extracts the requested element from an array, and converts the contents of its child arrays to objects of type $attributeName, or returns an array with a single element containing the value of that array element
public static extractAttributeAsArray ( array &$attribArray, string $attributeName ) : array
$attribArray array attributes from a search response
$attributeName string indicates which element of the passed array to extract
return array array of $attributeName objects, or a single element array
 public function fetch($query, $ids)
 {
     $criteria = [];
     foreach ($query as $term) {
         $criteria[$term->name] = $term->toparam();
     }
     $criteria["ids"] = SubscriptionSearch::ids()->in($ids)->toparam();
     $path = $this->_config->merchantPath() . '/subscriptions/advanced_search';
     $response = $this->_http->post($path, ['search' => $criteria]);
     return Util::extractAttributeAsArray($response['subscriptions'], 'subscription');
 }
Example #2
0
 public function testExtractAttributeAsArrayReturnsArrayOfObjects()
 {
     $attributes = ['verification' => [['status' => 'val1']]];
     $expected = new Braintree\CreditCardVerification(['status' => 'val1']);
     $this->assertEquals([$expected], Braintree\Util::extractAttributeAsArray($attributes, "verification"));
 }
 public function fetchExpiring($startDate, $endDate, $ids)
 {
     $queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate);
     $response = $this->_http->post($queryPath, ['search' => ['ids' => $ids]]);
     return Util::extractAttributeAsArray($response['paymentMethods'], 'creditCard');
 }
 public function testExtractAttributeAsArrayReturnsEmptyArray()
 {
     $attributes = [];
     $this->assertEquals([], Braintree\Util::extractAttributeAsArray($attributes, "foo"));
 }