<?php
 namespace Stripe\Service; abstract class AbstractService { protected $client; protected $streamingClient; public function __construct($client) { $this->client = $client; $this->streamingClient = $client; } public function getClient() { return $this->client; } public function getStreamingClient() { return $this->streamingClient; } private static function formatParams($params) { if (null === $params) { return null; } \array_walk_recursive($params, function (&$value, $key) { if (null === $value) { $value = ''; } }); return $params; } protected function request($method, $path, $params, $opts) { return $this->getClient()->request($method, $path, static::formatParams($params), $opts); } protected function requestStream($method, $path, $readBodyChunkCallable, $params, $opts) { return $this->getStreamingClient()->requestStream($method, $path, $readBodyChunkCallable, static::formatParams($params), $opts); } protected function requestCollection($method, $path, $params, $opts) { return $this->getClient()->requestCollection($method, $path, static::formatParams($params), $opts); } protected function requestSearchResult($method, $path, $params, $opts) { return $this->getClient()->requestSearchResult($method, $path, static::formatParams($params), $opts); } protected function buildPath($basePath, ...$ids) { foreach ($ids as $id) { if (null === $id || '' === \trim($id)) { $msg = 'The resource ID cannot be null or whitespace.'; throw new \Stripe\Exception\InvalidArgumentException($msg); } } return \sprintf($basePath, ...\array_map('\urlencode', $ids)); } } 