diff --git a/src/Guzzle/Common/Cache/CacheAdapterInterface.php b/src/Guzzle/Common/Cache/CacheAdapterInterface.php index d601dca2f..08e9fb040 100644 --- a/src/Guzzle/Common/Cache/CacheAdapterInterface.php +++ b/src/Guzzle/Common/Cache/CacheAdapterInterface.php @@ -27,7 +27,7 @@ interface CacheAdapterInterface * @return bool TRUE if a cache entry exists for the given cache id, * FALSE otherwise. */ - public function contains($id); + function contains($id); /** * Deletes a cache entry. @@ -36,7 +36,7 @@ public function contains($id); * * @return bool TRUE on success, FALSE on failure */ - public function delete($id); + function delete($id); /** * Fetches an entry from the cache. @@ -46,14 +46,14 @@ public function delete($id); * @return string The cached data or FALSE, if no cache entry exists * for the given id. */ - public function fetch($id); + function fetch($id); /** * Get the wrapped cache object * * @return mixed */ - public function getCacheObject(); + function getCacheObject(); /** * Puts data into the cache. @@ -66,5 +66,5 @@ public function getCacheObject(); * @return bool TRUE if the entry was successfully stored in the cache, * FALSE otherwise. */ - public function save($id, $data, $lifeTime = false); + function save($id, $data, $lifeTime = false); } \ No newline at end of file diff --git a/src/Guzzle/Common/Event/Observer.php b/src/Guzzle/Common/Event/Observer.php index 4cb93626a..0b33fa586 100644 --- a/src/Guzzle/Common/Event/Observer.php +++ b/src/Guzzle/Common/Event/Observer.php @@ -22,5 +22,5 @@ interface Observer * * @return null|bool|mixed */ - public function update(Subject $subject, $event, $context = null); + function update(Subject $subject, $event, $context = null); } \ No newline at end of file diff --git a/src/Guzzle/Common/Event/Subject.php b/src/Guzzle/Common/Event/Subject.php index 5f9280714..43a550942 100644 --- a/src/Guzzle/Common/Event/Subject.php +++ b/src/Guzzle/Common/Event/Subject.php @@ -18,5 +18,5 @@ interface Subject * * @return EventManager */ - public function getEventManager(); + function getEventManager(); } \ No newline at end of file diff --git a/src/Guzzle/Common/Filter/FilterInterface.php b/src/Guzzle/Common/Filter/FilterInterface.php index 7c1dfe80f..1afa8178f 100644 --- a/src/Guzzle/Common/Filter/FilterInterface.php +++ b/src/Guzzle/Common/Filter/FilterInterface.php @@ -22,5 +22,5 @@ interface FilterInterface * * @return bool Returns TRUE on success or FALSE on failure. */ - public function process($command); + function process($command); } \ No newline at end of file diff --git a/src/Guzzle/Common/Log/LogAdapterInterface.php b/src/Guzzle/Common/Log/LogAdapterInterface.php index b31ca6e41..86c72c2f6 100644 --- a/src/Guzzle/Common/Log/LogAdapterInterface.php +++ b/src/Guzzle/Common/Log/LogAdapterInterface.php @@ -24,14 +24,14 @@ interface LogAdapterInterface * @throws InvalidArgumentException if the supplied object does not implement the * correct interface. */ - public function __construct($logObject); + function __construct($logObject); /** * Get the adapted log object * * @return mixed */ - public function getLogObject(); + function getLogObject(); /** * Log a message at a priority @@ -42,5 +42,5 @@ public function getLogObject(); * * @return LogAdapterInterface */ - public function log($message, $priority = LOG_INFO, $extras = null); + function log($message, $priority = LOG_INFO, $extras = null); } \ No newline at end of file diff --git a/src/Guzzle/Http/CookieJar/CookieJarInterface.php b/src/Guzzle/Http/CookieJar/CookieJarInterface.php index 4ffa1b158..6f389db4e 100644 --- a/src/Guzzle/Http/CookieJar/CookieJarInterface.php +++ b/src/Guzzle/Http/CookieJar/CookieJarInterface.php @@ -29,7 +29,7 @@ interface CookieJarInterface * * @return int Returns the number of deleted cookies */ - public function clear($domain = null, $path = null, $name = null); + function clear($domain = null, $path = null, $name = null); /** * Discard all temporary cookies. @@ -40,14 +40,14 @@ public function clear($domain = null, $path = null, $name = null); * * @return int Returns the number of deleted cookies */ - public function clearTemporary(); + function clearTemporary(); /** * Delete any expired cookies * * @return int Returns the number of deleted cookies */ - public function deleteExpired(); + function deleteExpired(); /** * Get all of the matching cookies @@ -75,7 +75,7 @@ public function deleteExpired(); * port (string) - CSV list of ports * http_only (bool) - HTTP only cookie */ - public function getCookies($domain = null, $path = null, $name = null, $skipDiscardable = false, $skipExpired = true); + function getCookies($domain = null, $path = null, $name = null, $skipDiscardable = false, $skipExpired = true); /** * Save a cookie @@ -95,5 +95,5 @@ public function getCookies($domain = null, $path = null, $name = null, $skipDisc * * @return CookieJarInterface */ - public function save(array $cookieData); + function save(array $cookieData); } \ No newline at end of file diff --git a/src/Guzzle/Http/Curl/CurlFactoryInterface.php b/src/Guzzle/Http/Curl/CurlFactoryInterface.php index 676981787..af1e432d7 100644 --- a/src/Guzzle/Http/Curl/CurlFactoryInterface.php +++ b/src/Guzzle/Http/Curl/CurlFactoryInterface.php @@ -22,7 +22,7 @@ interface CurlFactoryInterface * * @return resource */ - public function getHandle(RequestInterface $request); + function getHandle(RequestInterface $request); /** * Release a cURL handle back to the factory @@ -32,5 +32,5 @@ public function getHandle(RequestInterface $request); * * @return CurlFactoryInterface */ - public function releaseHandle(CurlHandle $handle); + function releaseHandle(CurlHandle $handle); } \ No newline at end of file diff --git a/src/Guzzle/Http/Message/EntityEnclosingRequestInterface.php b/src/Guzzle/Http/Message/EntityEnclosingRequestInterface.php index e69170108..799b5a279 100644 --- a/src/Guzzle/Http/Message/EntityEnclosingRequestInterface.php +++ b/src/Guzzle/Http/Message/EntityEnclosingRequestInterface.php @@ -25,21 +25,21 @@ interface EntityEnclosingRequestInterface extends RequestInterface, Observer * * @return EntityEnclosingRequestInterface */ - public function setBody($body); + function setBody($body); /** * Get the body of the request if set * * @return EntityBody|null */ - public function getBody(); + function getBody(); /** * Get the post fields that will be used in the request * * @return QueryString */ - public function getPostFields(); + function getPostFields(); /** * Returns an array of files that will be sent in the request. @@ -48,7 +48,7 @@ public function getPostFields(); * * @return array */ - public function getPostFiles(); + function getPostFiles(); /** * Add the POST fields to use in the request @@ -57,7 +57,7 @@ public function getPostFiles(); * * @return EntityEnclosingRequestInterface */ - public function addPostFields($fields); + function addPostFields($fields); /** * Add POST files to use in the upload @@ -68,5 +68,5 @@ public function addPostFields($fields); * * @throws BodyException if the file cannot be read */ - public function addPostFiles(array $files); + function addPostFiles(array $files); } \ No newline at end of file diff --git a/src/Guzzle/Http/Message/MessageInterface.php b/src/Guzzle/Http/Message/MessageInterface.php index 6f1cce0e8..0fe48dc44 100644 --- a/src/Guzzle/Http/Message/MessageInterface.php +++ b/src/Guzzle/Http/Message/MessageInterface.php @@ -22,7 +22,7 @@ interface MessageInterface * * @return Collection */ - public function getParams(); + function getParams(); /** * Add and merge in an array of HTTP headers. @@ -31,7 +31,7 @@ public function getParams(); * * @return MessageInterface */ - public function addHeaders(array $headers); + function addHeaders(array $headers); /** * Retrieve an HTTP header by name @@ -44,7 +44,7 @@ public function addHeaders(array $headers); * @return string|null Returns the matching HTTP header or NULL if the * header is not found */ - public function getHeader($header, $default = null); + function getHeader($header, $default = null); /** * Get all or all matching headers. @@ -57,7 +57,7 @@ public function getHeader($header, $default = null); * specified, or an array of only the headers matching the values in * the $names array. */ - public function getHeaders(array $headers = null); + function getHeaders(array $headers = null); /** * Returns TRUE or FALSE if the specified header is present. @@ -69,7 +69,7 @@ public function getHeaders(array $headers = null); * * @return bool Returns TRUE if the header is present and FALSE if not set */ - public function hasHeader($header, $caseInsensitive = false); + function hasHeader($header, $caseInsensitive = false); /** * Remove a specific HTTP header. @@ -78,7 +78,7 @@ public function hasHeader($header, $caseInsensitive = false); * * @return MessageInterface */ - public function removeHeader($header); + function removeHeader($header); /** * Set an HTTP header @@ -88,7 +88,7 @@ public function removeHeader($header); * * @return MessageInterface */ - public function setHeader($header, $value); + function setHeader($header, $value); /** * Overwrite all HTTP headers with the supplied array of headers @@ -97,14 +97,14 @@ public function setHeader($header, $value); * * @return MessageInterface */ - public function setHeaders(array $headers); + function setHeaders(array $headers); /** * Get the raw message headers as a string * * @return string */ - public function getRawHeaders(); + function getRawHeaders(); /** * Get a Cache-Control directive from the message @@ -113,7 +113,7 @@ public function getRawHeaders(); * * @return null|string */ - public function getCacheControlDirective($directive); + function getCacheControlDirective($directive); /** * Check if the message has a Cache-Control directive @@ -122,7 +122,7 @@ public function getCacheControlDirective($directive); * * @return bool */ - public function hasCacheControlDirective($directive); + function hasCacheControlDirective($directive); /** * Add a Cache-Control directive on the message @@ -132,7 +132,7 @@ public function hasCacheControlDirective($directive); * * @return MessageInterface */ - public function addCacheControlDirective($directive, $value); + function addCacheControlDirective($directive, $value); /** * Remove a Cache-Control directive from the message @@ -141,5 +141,5 @@ public function addCacheControlDirective($directive, $value); * * @return MessageInterface */ - public function removeCacheControlDirective($directive); + function removeCacheControlDirective($directive); } \ No newline at end of file diff --git a/src/Guzzle/Http/Message/RequestInterface.php b/src/Guzzle/Http/Message/RequestInterface.php index 5bdda4abb..66fc5b898 100644 --- a/src/Guzzle/Http/Message/RequestInterface.php +++ b/src/Guzzle/Http/Message/RequestInterface.php @@ -46,19 +46,19 @@ interface RequestInterface extends MessageInterface, Subject * @param array|Collection $headers (optional) HTTP headers * @param CurlFactoryInterface $curlFactory (optional) Curl factory object */ - public function __construct($method, $url, $headers = array(), CurlFactoryInterface $curlFactory = null); + function __construct($method, $url, $headers = array(), CurlFactoryInterface $curlFactory = null); /** * Clone the request object, leaving off any response that was received */ - public function __clone(); + function __clone(); /** * Get the HTTP request as a string * * @return string */ - public function __toString(); + function __toString(); /** * Set the URL of the request @@ -70,7 +70,7 @@ public function __toString(); * * @return RequestInterface */ - public function setUrl($url); + function setUrl($url); /** * Send the request @@ -78,7 +78,7 @@ public function setUrl($url); * @return Response * @throws RequestException on a request error */ - public function send(); + function send(); /** * Get the previously received {@see Response} or NULL if the request has @@ -86,7 +86,7 @@ public function send(); * * @return Response|null */ - public function getResponse(); + function getResponse(); /** * Get the collection of key value pairs that will be used as the query @@ -94,21 +94,21 @@ public function getResponse(); * * @return QueryString */ - public function getQuery(); + function getQuery(); /** * Get the HTTP method of the request * * @return string */ - public function getMethod(); + function getMethod(); /** * Get the URI scheme of the request (http, https, ftp, etc) * * @return string */ - public function getScheme(); + function getScheme(); /** * Set the URI scheme of the request (http, https, ftp, etc) @@ -117,14 +117,14 @@ public function getScheme(); * * @return RequestInterface */ - public function setScheme($scheme); + function setScheme($scheme); /** * Get the host of the request * * @return string */ - public function getHost(); + function getHost(); /** * Set the host of the request. Including a port in the host will modify @@ -134,7 +134,7 @@ public function getHost(); * * @return RequestInterface */ - public function setHost($host); + function setHost($host); /** * Get the HTTP protocol version of the request @@ -144,7 +144,7 @@ public function setHost($host); * * @return string|int */ - public function getProtocolVersion($curlValue = false); + function getProtocolVersion($curlValue = false); /** * Set the HTTP protocol version of the request (e.g. 1.1 or 1.0) @@ -153,14 +153,14 @@ public function getProtocolVersion($curlValue = false); * * @return RequestInterface */ - public function setProtocolVersion($protocol); + function setProtocolVersion($protocol); /** * Get the path of the request (e.g. '/', '/index.html') * * @return string */ - public function getPath(); + function getPath(); /** * Set the path of the request (e.g. '/', '/index.html') @@ -169,14 +169,14 @@ public function getPath(); * * @return RequestInterface */ - public function setPath($path); + function setPath($path); /** * Get the port that the request will be sent on if it has been set * * @return int|null */ - public function getPort(); + function getPort(); /** * Set the port that the request will be sent on @@ -185,14 +185,14 @@ public function getPort(); * * @return RequestInterface */ - public function setPort($port); + function setPort($port); /** * Get the username to pass in the URL if set * * @return string|null */ - public function getUsername(); + function getUsername(); /** * Set HTTP authorization parameters @@ -206,14 +206,14 @@ public function getUsername(); * @see http://www.ietf.org/rfc/rfc2617.txt * @throws RequestException */ - public function setAuth($user, $password = '', $scheme = 'Basic'); + function setAuth($user, $password = '', $scheme = 'Basic'); /** * Get the password to pass in the URL if set * * @return string|null */ - public function getPassword(); + function getPassword(); /** * Get the URI of the request (e.g. '/', '/index.html', '/index.html?q=1) @@ -221,7 +221,7 @@ public function getPassword(); * * @return string */ - public function getResourceUri(); + function getResourceUri(); /** * Get the full URL of the request (e.g. 'http://www.guzzle-project.com/') @@ -230,14 +230,14 @@ public function getResourceUri(); * * @return string */ - public function getUrl(); + function getUrl(); /** * Get the state of the request. One of 'complete', 'sending', 'new' * * @return string */ - public function getState(); + function getState(); /** * Set the state of the request @@ -246,14 +246,14 @@ public function getState(); * * @return RequestInterface */ - public function setState($state); + function setState($state); /** * Get the cURL options that will be applied when the cURL handle is created * * @return Collection */ - public function getCurlOptions(); + function getCurlOptions(); /** * Get the cURL handle @@ -267,7 +267,7 @@ public function getCurlOptions(); * * @return CurlHandle|null Returns NULL if no handle should be created */ - public function getCurlHandle(); + function getCurlHandle(); /** * Set the factory that will create cURL handles based on the request @@ -276,7 +276,7 @@ public function getCurlHandle(); * * @return Request */ - public function setCurlFactory(CurlFactoryInterface $factory); + function setCurlFactory(CurlFactoryInterface $factory); /** * Method to receive HTTP response headers as they are retrieved @@ -285,7 +285,7 @@ public function setCurlFactory(CurlFactoryInterface $factory); * * @return integer Returns the size of the data. */ - public function receiveResponseHeader($data); + function receiveResponseHeader($data); /** * Set the EntityBody that will hold the response message's entity body. @@ -299,14 +299,14 @@ public function receiveResponseHeader($data); * * @return Request */ - public function setResponseBody(EntityBody $body); + function setResponseBody(EntityBody $body); /** * Determine if the response body is repeatable (readable + seekable) * * @return bool */ - public function isResponseBodyRepeatable(); + function isResponseBodyRepeatable(); /** * Manually set a response for the request. @@ -321,7 +321,7 @@ public function isResponseBodyRepeatable(); * * @return RequestInterface Returns a reference to the object. */ - public function setResponse(Response $response, $queued = false); + function setResponse(Response $response, $queued = false); /** * Get an array of Cookies or a specific cookie from the request @@ -334,7 +334,7 @@ public function setResponse(Response $response, $queued = false); * not modify the request's cookies. You will need to set the cookie * back on the request after modifying the object. */ - public function getCookie($name = null); + function getCookie($name = null); /** * Set the Cookie header using an array or Cookie object @@ -343,7 +343,7 @@ public function getCookie($name = null); * * @return RequestInterface */ - public function setCookie($cookies); + function setCookie($cookies); /** * Add a Cookie value by name to the Cookie header @@ -353,7 +353,7 @@ public function setCookie($cookies); * * @return RequestInterface */ - public function addCookie($name, $value); + function addCookie($name, $value); /** * Remove the cookie header or a specific cookie value by name @@ -363,14 +363,14 @@ public function addCookie($name, $value); * * @return RequestInterface */ - public function removeCookie($name = null); + function removeCookie($name = null); /** * Returns whether or not the response served to the request can be cached * * @return bool */ - public function canCache(); + function canCache(); /** * Setting an onComplete method will override the default behavior of @@ -388,12 +388,12 @@ public function canCache(); * @return RequestInterface * @throws InvalidArgumentException if the method is not callable */ - public function setOnComplete($callable); + function setOnComplete($callable); /** * Release the cURL handle if one is claimed * * @return RequestInterface */ - public function releaseCurlHandle(); + function releaseCurlHandle(); } \ No newline at end of file diff --git a/src/Guzzle/Http/Pool/PoolInterface.php b/src/Guzzle/Http/Pool/PoolInterface.php index aef27e330..1ddf09e26 100644 --- a/src/Guzzle/Http/Pool/PoolInterface.php +++ b/src/Guzzle/Http/Pool/PoolInterface.php @@ -35,21 +35,21 @@ interface PoolInterface extends Subject, \Countable * * @param RequestInterface $request Returns the Request that was added */ - public function add(RequestInterface $request); + function add(RequestInterface $request); /** * Get an array of attached {@see RequestInterface}s. * * @return array Returns an array of attached requests. */ - public function all(); + function all(); /** * Get the current state of the Pool * * @return string */ - public function getState(); + function getState(); /** * Remove a request from the pool. @@ -58,12 +58,12 @@ public function getState(); * * @return RequestInterface Returns the Request object that was removed */ - public function remove(RequestInterface $request); + function remove(RequestInterface $request); /** * Reset the state of the Pool and remove any attached RequestInterface objects */ - public function reset(); + function reset(); /** * Send a pool of {@see RequestInterface} requests. @@ -76,5 +76,5 @@ public function reset(); * @throws PoolRequestException if any requests threw exceptions during the * transfer. */ - public function send(); + function send(); } \ No newline at end of file diff --git a/src/Guzzle/Service/Client.php b/src/Guzzle/Service/Client.php index 9980ca5c1..fdc9955c3 100644 --- a/src/Guzzle/Service/Client.php +++ b/src/Guzzle/Service/Client.php @@ -24,7 +24,7 @@ use Guzzle\Service\Description\ServiceDescription; /** - * Client object for executing commands on a webservice. + * Client object for executing commands on a web service. * * Signals emitted: * @@ -37,7 +37,7 @@ * * @author michael@guzzlephp.org */ -class Client extends AbstractSubject +class Client extends AbstractSubject implements ClientInterface { /** * @var ServiceDescription Description of the service and possible commands @@ -357,7 +357,7 @@ public function getBaseUrl($inject = true) * * @return Client */ - public final function setBaseUrl($url) + public function setBaseUrl($url) { $this->baseUrl = $url; if ($this->config || strpos($url, '{{') === false) { @@ -375,7 +375,7 @@ public final function setBaseUrl($url) * * @return Client */ - public final function setDescription(ServiceDescription $service) + public function setDescription(ServiceDescription $service) { $this->serviceDescription = $service; @@ -387,7 +387,7 @@ public final function setDescription(ServiceDescription $service) * * @return ServiceDescription|NullObject */ - public final function getDescription() + public function getDescription() { return $this->serviceDescription ?: new NullObject(); } @@ -401,7 +401,7 @@ public final function getDescription() * * @return Client */ - public final function setUserApplication($appName, $version) + public function setUserApplication($appName, $version) { $this->userApplication = $appName . '/' . ($version ?: '1.0'); @@ -446,7 +446,6 @@ public final function head($uri = null, $inject = null) * @param array|Collection (optional) Parameters to replace from the uri * {{}} injection points. * - * * @return Request */ public final function delete($uri = null, $inject = null) diff --git a/src/Guzzle/Service/ClientInterface.php b/src/Guzzle/Service/ClientInterface.php new file mode 100644 index 000000000..2ca0f1b44 --- /dev/null +++ b/src/Guzzle/Service/ClientInterface.php @@ -0,0 +1,244 @@ + + * @license See the LICENSE file that was distributed with this source code. + */ + +namespace Guzzle\Service; + +use Guzzle\Guzzle; +use Guzzle\Common\Collection; +use Guzzle\Common\Event\Subject; +use Guzzle\Common\NullObject; +use Guzzle\Http\Message\RequestInterface; +use Guzzle\Service\Command\CommandInterface; +use Guzzle\Service\Command\CommandSet; +use Guzzle\Service\Description\ServiceDescription; + +/** + * Client interface for executing commands on a web service. + * + * @author michael@guzzlephp.org + */ +interface ClientInterface extends Subject +{ + /** + * Basic factory method to create a new client. Extend this method in + * subclasses to build more complex clients. + * + * @param array|Collection $config (optiona) Configuartion data + * + * @return ClientInterface + */ + static function factory($config); + + /** + * Set the configuration object to use with the client + * + * @param array|Collection|string $config Parameters that define how the + * client behaves and connects to a webservice. Pass an array or a + * Collection object. + * + * @return ClientInterface + */ + function setConfig($config); + + /** + * Get a configuration setting or all of the configuration settings + * + * @param bool|string $key Configuration value to retrieve. Set to FALSE + * to retrieve all values of the client. The object return can be + * modified, and modifications will affect the client's config. + * + * @return mixed|Collection + */ + function getConfig($key = false); + + /** + * Inject configuration values into a formatted string with {{param}} as a + * parameter delimiter (replace param with the configuration value name) + * + * @param string $string String to inject config values into + * + * @return string + */ + function inject($string); + + /** + * Create and return a new {@see RequestInterface} configured for the client + * + * @param string $method (optional) HTTP method. Defaults to GET + * @param string $uri (optional) Resource URI. Use an absolute path to + * override the base path of the client, or a relative path to append + * to the base path of the client. The URI can contain the + * querystring as well. + * @param array|Collection (optional) Parameters to replace from the uri + * {{}} injection points. + * + * @return RequestInterface + */ + function createRequest($method = RequestInterface::GET, $uri = null, $inject = null); + + /** + * Prepare a request to be sent from the Client by adding client specific + * behaviors and properties to the request. + * + * This method should only be called when using the default RequestFactory + * is not an option and the request sent from the client must be created + * manually. + * + * @param RequestInterface $request Request to prepare for the client + * + * @return RequestInterface + */ + function prepareRequest(RequestInterface $request); + + /** + * Get a command by name. First, the client will see if it has a service + * description and if the service description defines a command by the + * supplied name. If no dynamic command is found, the client will look for + * a concrete command class exists matching the name supplied. If neither + * are found, an InvalidArgumentException is thrown. + * + * @param string $name Name of the command to retrieve + * @param array $args (optional) Arguments to pass to the command + * + * @return CommandInterface + * @throws InvalidArgumentException if no command can be found by name + */ + function getCommand($name, array $args = array()); + + /** + * Execute a command and return the response + * + * @param CommandInterface|CommandSet $command The command or set to execute + * + * @return mixed Returns the result of the executed command's + * {@see CommandInterface::getResult} method if a CommandInterface is + * passed, or the CommandSet itself if a CommandSet is passed + * @throws InvalidArgumentException if an invalid command is passed + * @throws Command\CommandSetException if a set contains commands associated + * with other clients + */ + function execute($command); + + /** + * Get the base service endpoint URL with configuration options injected + * into the configuration setting. + * + * @param bool $inject (optional) Set to FALSE to get the raw base URL + * + * @return string + * @throws RuntimeException if a base URL has not been set + */ + function getBaseUrl($inject = true); + + /** + * Set the base service endpoint URL + * + * @param string $url The base service endpoint URL of the webservice + * + * @return ClientInterface + */ + function setBaseUrl($url); + + /** + * Set the service description of the client + * + * @param ServiceDescription $description Service description that describes + * all of the commands and information of the client + * + * @return ClientInterface + */ + function setDescription(ServiceDescription $service); + + /** + * Get the service description of the client + * + * @return ServiceDescription|NullObject + */ + function getDescription(); + + /** + * Set the name of your application and application version that will be + * appended to the User-Agent header of all reqeusts. + * + * @param string $appName Name of your application + * @param string $version Version number of your application + * + * @return ClientInterface + */ + function setUserApplication($appName, $version); + + /** + * Create a GET request for the client + * + * @param string $uri (optional) Resource URI of the request. Use an + * absolute path to override the base path, or a relative path to append + * @param array|Collection (optional) Parameters to replace from the uri + * {{}} injection points. + * + * @return Request + */ + function get($uri = null, $inject = null); + + /** + * Create a HEAD request for the client + * + * @param string $uri (optional) Resource URI of the request. Use an + * absolute path to override the base path, or a relative path to append + * @param array|Collection (optional) Parameters to replace from the uri + * {{}} injection points. + * + * @return Request + */ + function head($uri = null, $inject = null); + + /** + * Create a DELETE request for the client + * + * @param string $uri (optional) Resource URI of the request. Use an + * absolute path to override the base path, or a relative path to append + * @param array|Collection (optional) Parameters to replace from the uri + * {{}} injection points. + * + * @return Request + */ + function delete($uri = null, $inject = null); + + /** + * Create a PUT request for the client + * + * @param string $uri (optional) Resource URI of the request. Use an + * absolute path to override the base path, or a relative path to append + * @param array|Collection (optional) Parameters to replace from the uri + * {{}} injection points. + * + * @return EntityEnclosingRequest + */ + function put($uri = null, $inject = null); + + /** + * Create a POST request for the client + * + * @param string $uri (optional) Resource URI of the request. Use an absolute path to + * override the base path, or a relative path to append it. + * @param array|Collection (optional) Parameters to replace from the uri + * {{}} injection points. + * + * @return EntityEnclosingRequest + */ + function post($uri = null, $inject = null); + + /** + * Create an OPTIONS request for the client + * + * @param string $uri (optional) Resource URI of the request. Use an + * absolute path to override the base path, or relative path to append + * @param array|Collection (optional) Parameters to replace from the uri + * {{}} injection points. + * + * @return Request + */ + function options($uri = null, $inject = null); +} \ No newline at end of file diff --git a/src/Guzzle/Service/Command/AbstractCommand.php b/src/Guzzle/Service/Command/AbstractCommand.php index db8391a93..805fc7f91 100644 --- a/src/Guzzle/Service/Command/AbstractCommand.php +++ b/src/Guzzle/Service/Command/AbstractCommand.php @@ -12,7 +12,7 @@ use Guzzle\Http\Message\Response; use Guzzle\Http\Message\RequestInterface; use Guzzle\Service\Description\ApiCommand; -use Guzzle\Service\Client; +use Guzzle\Service\ClientInterface; /** * Command object to handle preparing and processing client requests and @@ -23,7 +23,7 @@ abstract class AbstractCommand extends Collection implements CommandInterface { /** - * @var Client The client object used to execute the command + * @var ClientInterface Client object used to execute the command */ protected $client; @@ -132,7 +132,7 @@ public function execute() /** * Get the client object that will execute the command * - * @return Client|null + * @return ClientInterface|null */ public function getClient() { @@ -142,11 +142,11 @@ public function getClient() /** * Set the client objec that will execute the command * - * @param Client $client The client objec that will execute the command + * @param ClientInterface $client The client objec that will execute the command * * @return Command */ - public function setClient(Client $client) + public function setClient(ClientInterface $client) { $this->client = $client; diff --git a/src/Guzzle/Service/Command/CommandInterface.php b/src/Guzzle/Service/Command/CommandInterface.php index 21f6ac84c..8d00315a5 100644 --- a/src/Guzzle/Service/Command/CommandInterface.php +++ b/src/Guzzle/Service/Command/CommandInterface.php @@ -9,7 +9,7 @@ use Guzzle\Common\Collection; use Guzzle\Http\Message\Response; use Guzzle\Http\Message\RequestInterface; -use Guzzle\Service\Client; +use Guzzle\Service\ClientInterface; use Guzzle\Service\Description\ApiCommand; /** @@ -27,28 +27,28 @@ interface CommandInterface * to set on the command * @param ApiCommand $apiCommand (optional) Command definition from description */ - public function __construct($parameters = null, ApiCommand $apiCommand = null); + function __construct($parameters = null, ApiCommand $apiCommand = null); /** * Get the short form name of the command * * @return string */ - public function getName(); + function getName(); /** * Get the API command information about the command * * @return ApiCommand|NullObject */ - public function getApiCommand(); + function getApiCommand(); /** * Get whether or not the command can be batched * * @return bool */ - public function canBatch(); + function canBatch(); /** * Execute the command @@ -56,23 +56,23 @@ public function canBatch(); * @return Command * @throws RuntimeException if a client has not been associated with the command */ - public function execute(); + function execute(); /** * Get the client object that will execute the command * - * @return Client|null + * @return ClientInterface|null */ - public function getClient(); + function getClient(); /** * Set the client objec that will execute the command * - * @param Client $client The client objec that will execute the command + * @param ClientInterface $client The client objec that will execute the command * * @return Command */ - public function setClient(Client $client); + function setClient(ClientInterface $client); /** * Get the request object associated with the command @@ -80,7 +80,7 @@ public function setClient(Client $client); * @return RequestInterface * @throws RuntimeException if the command has not been executed */ - public function getRequest(); + function getRequest(); /** * Get the response object associated with the command @@ -88,7 +88,7 @@ public function getRequest(); * @return Response * @throws RuntimeException if the command has not been executed */ - public function getResponse(); + function getResponse(); /** * Get the result of the command @@ -97,21 +97,21 @@ public function getResponse(); * object unless overridden in a subclass * @throws RuntimeException if the command has not been executed */ - public function getResult(); + function getResult(); /** * Returns TRUE if the command has been prepared for executing * * @return bool */ - public function isPrepared(); + function isPrepared(); /** * Returns TRUE if the command has been executed * * @return bool */ - public function isExecuted(); + function isExecuted(); /** * Prepare the command for executing and create a request object. @@ -120,7 +120,7 @@ public function isExecuted(); * @throws RuntimeException if a client object has not been set previously * or in the prepare() */ - public function prepare(); + function prepare(); /** * Get the object that manages the request headers that will be set on any @@ -128,5 +128,5 @@ public function prepare(); * * @return Collection */ - public function getRequestHeaders(); + function getRequestHeaders(); } \ No newline at end of file diff --git a/src/Guzzle/Service/Command/CommandSet.php b/src/Guzzle/Service/Command/CommandSet.php index 5b5be4917..c6aaac034 100644 --- a/src/Guzzle/Service/Command/CommandSet.php +++ b/src/Guzzle/Service/Command/CommandSet.php @@ -10,16 +10,16 @@ use Guzzle\Common\Event\Subject; use Guzzle\Http\Pool\PoolInterface; use Guzzle\Http\Pool\Pool; -use Guzzle\Service\Client; +use Guzzle\Service\ClientInterface; use Guzzle\Service\Command\CommandInterface; /** * Container for sending sets of {@see CommandInterface} - * objects through {@see Client} object. + * objects through {@see ClientInterface} object. * * Commands from different services using different clients can be sent in - * parallel if each command has an associated {@see Client} before executing - * the set. + * parallel if each command has an associated {@see ClientInterface} before + * executing the set. * * @author Michael Dowling */ @@ -82,11 +82,11 @@ public function count() * * @return CommandSet * @throws CommandSetException if any of the commands do not have an associated - * {@see Client} object + * {@see ClientInterface} object */ public function execute() { - // Keep a list of all commands with no Client + // Keep a list of all commands with no client $invalid = array(); foreach ($this->commands as $command) { if (!$command->getClient()) { @@ -94,9 +94,9 @@ public function execute() } } - // If any commands do not have a Client, then throw an exception + // If any commands do not have a client, then throw an exception if (count($invalid)) { - $e = new CommandSetException('Commands found with no associated Client'); + $e = new CommandSetException('Commands found with no associated client'); $e->setCommands($invalid); throw $e; } @@ -112,7 +112,7 @@ public function execute() $parallel = $this->getParallelCommands(); if (count($parallel)) { $this->pool->reset(); - // Prepare each request and send out Client notifications + // Prepare each request and send out client notifications foreach ($parallel as $command) { $request = $command->prepare(); $request->getParams()->set('command', $command); diff --git a/src/Guzzle/Service/Description/CommandFactoryInterface.php b/src/Guzzle/Service/Description/CommandFactoryInterface.php index f1ce11cbf..ad9530ef7 100644 --- a/src/Guzzle/Service/Description/CommandFactoryInterface.php +++ b/src/Guzzle/Service/Description/CommandFactoryInterface.php @@ -22,5 +22,5 @@ interface CommandFactoryInterface * @return Guzzle\Service\Command\CommandInterface * @throws InvalidArgumentException if the command was not found */ - public function createCommand(ApiCommand $command, array $args); + function createCommand(ApiCommand $command, array $args); } \ No newline at end of file diff --git a/src/Guzzle/Service/Description/DescriptionBuilderInterface.php b/src/Guzzle/Service/Description/DescriptionBuilderInterface.php index a83a3d0e6..c7a36e17b 100644 --- a/src/Guzzle/Service/Description/DescriptionBuilderInterface.php +++ b/src/Guzzle/Service/Description/DescriptionBuilderInterface.php @@ -18,5 +18,5 @@ interface DescriptionBuilderInterface * * @return ServiceDescription */ - public function build(); + function build(); } \ No newline at end of file diff --git a/src/Guzzle/Service/ResourceIterator.php b/src/Guzzle/Service/ResourceIterator.php index 7d76c778c..0406e0f05 100644 --- a/src/Guzzle/Service/ResourceIterator.php +++ b/src/Guzzle/Service/ResourceIterator.php @@ -7,7 +7,6 @@ namespace Guzzle\Service; use Guzzle\Common\Event\AbstractSubject; -use Guzzle\Service\Client; /** * Iterate over a paginated set of resources that requires subsequent paginated @@ -28,7 +27,7 @@ abstract class ResourceIterator extends AbstractSubject implements \Iterator, \Countable { /** - * @var Client + * @var ClientInterface */ protected $client; @@ -78,9 +77,9 @@ abstract class ResourceIterator extends AbstractSubject implements \Iterator, \C protected $data = array(); /** - * Constructor. This should only be invoked by a {@see Client} object. + * This should only be invoked by a {@see ClientInterface} object. * - * @param Client $client Client responsible for sending subsquent requests + * @param ClientInterface $client Client responsible for sending requests * * @param array $data Associative array of additional parameters, including * any initial data to be iterated. @@ -91,7 +90,7 @@ abstract class ResourceIterator extends AbstractSubject implements \Iterator, \C *
  • next_token => The value used to mark the beginning of a subsequent result set.
  • * */ - public function __construct(Client $client, array $data) + public function __construct(ClientInterface $client, array $data) { $this->client = $client; $this->data = $data; diff --git a/src/Guzzle/Service/ServiceBuilder.php b/src/Guzzle/Service/ServiceBuilder.php index 9eadf7d9b..3f0d68207 100644 --- a/src/Guzzle/Service/ServiceBuilder.php +++ b/src/Guzzle/Service/ServiceBuilder.php @@ -88,7 +88,7 @@ public static function factory($xml, CacheAdapterInterface $cacheAdapter = null, if ($cacheAdapter) { $cacheAdapter->save($key, serialize($config), $ttl); } - + return new self($config); } @@ -112,7 +112,7 @@ public function __construct(array $serviceBuilderConfig) * @param bool $throwAway (optional) Set to TRUE to not store the client * for later retrieval from the ServiceBuilder * - * @return Client + * @return ClientInterface * @throws InvalidArgumentException when a client cannot be found by name */ public function get($name, $throwAway = false) @@ -141,7 +141,7 @@ public function get($name, $throwAway = false) * Register a client by name with the service builder * * @param string $offset Name of the client to register - * @param Client $value Client to register + * @param ClientInterface $value Client to register * * @return ServiceBuilder */ @@ -185,7 +185,7 @@ public function offsetExists($offset) * * @param string $offset Registered client name to retrieve * - * @return Client + * @return ClientInterface */ public function offsetGet($offset) {