mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-08 18:48:22 +01:00
35 lines
1019 B
PHP
35 lines
1019 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 \Stripe\Error\Api($message);
|
|
}
|
|
$obj->setLastResponse($response);
|
|
$obj->setRequestParams($params);
|
|
return $obj;
|
|
}
|
|
}
|