composer package updates
[openemr.git] / vendor / stripe / stripe-php / lib / ApiOperations / All.php
blobd1c6424816f342bcf3c0b3c546a858541e88bda8
1 <?php
3 namespace Stripe\ApiOperations;
5 /**
6 * Trait for listable resources. Adds a `all()` static method to the class.
8 * This trait should only be applied to classes that derive from StripeObject.
9 */
10 trait All
12 /**
13 * @param array|null $params
14 * @param array|string|null $opts
16 * @return \Stripe\Collection of ApiResources
18 public static function all($params = null, $opts = null)
20 self::_validateParams($params);
21 $url = static::classUrl();
23 list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
24 $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
25 if (!is_a($obj, 'Stripe\\Collection')) {
26 $class = get_class($obj);
27 $message = "Expected type \"Stripe\\Collection\", got \"$class\" instead";
28 throw new Error\Api($message);
30 $obj->setLastResponse($response);
31 $obj->setRequestParams($params);
32 return $obj;