2
0
forked from Wavyzz/dolibarr
Files
dolibarr-fork/htdocs/includes/stripe/lib/ApiOperations/All.php
2018-03-07 19:26:06 +01:00

35 lines
1011 B
PHP

<?php
namespace Stripe\ApiOperations;
/**
* Trait for listable resources. Adds a `all()` static method to the class.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait All
{
/**
* @param array|null $params
* @param array|string|null $opts
*
* @return \Stripe\Collection of ApiResources
*/
public static function all($params = null, $opts = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
if (!is_a($obj, 'Stripe\\Collection')) {
$class = get_class($obj);
$message = "Expected type \"Stripe\\Collection\", got \"$class\" instead";
throw new Error\Api($message);
}
$obj->setLastResponse($response);
$obj->setRequestParams($params);
return $obj;
}
}