diff options
Diffstat (limited to 'apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common')
13 files changed, 732 insertions, 0 deletions
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/AbstractHasDispatcher.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/AbstractHasDispatcher.php new file mode 100644 index 00000000000..9c6874fb4e4 --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/AbstractHasDispatcher.php @@ -0,0 +1,49 @@ +<?php + +namespace Guzzle\Common; + +use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * Class that holds an event dispatcher + */ +class AbstractHasDispatcher implements HasDispatcherInterface +{ + /** @var EventDispatcherInterface */ + protected $eventDispatcher; + + public static function getAllEvents() + { + return array(); + } + + public function setEventDispatcher(EventDispatcherInterface $eventDispatcher) + { + $this->eventDispatcher = $eventDispatcher; + + return $this; + } + + public function getEventDispatcher() + { + if (!$this->eventDispatcher) { + $this->eventDispatcher = new EventDispatcher(); + } + + return $this->eventDispatcher; + } + + public function dispatch($eventName, array $context = array()) + { + $this->getEventDispatcher()->dispatch($eventName, new Event($context)); + } + + public function addSubscriber(EventSubscriberInterface $subscriber) + { + $this->getEventDispatcher()->addSubscriber($subscriber); + + return $this; + } +} diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Collection.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Collection.php new file mode 100644 index 00000000000..5cb1535d07a --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Collection.php @@ -0,0 +1,403 @@ +<?php + +namespace Guzzle\Common; + +use Guzzle\Common\Exception\InvalidArgumentException; +use Guzzle\Common\Exception\RuntimeException; + +/** + * Key value pair collection object + */ +class Collection implements \ArrayAccess, \IteratorAggregate, \Countable, ToArrayInterface +{ + /** @var array Data associated with the object. */ + protected $data; + + /** + * @param array $data Associative array of data to set + */ + public function __construct(array $data = array()) + { + $this->data = $data; + } + + /** + * Create a new collection from an array, validate the keys, and add default values where missing + * + * @param array $config Configuration values to apply. + * @param array $defaults Default parameters + * @param array $required Required parameter names + * + * @return self + * @throws InvalidArgumentException if a parameter is missing + */ + public static function fromConfig(array $config = array(), array $defaults = array(), array $required = array()) + { + $data = $config + $defaults; + + if ($missing = array_diff($required, array_keys($data))) { + throw new InvalidArgumentException('Config is missing the following keys: ' . implode(', ', $missing)); + } + + return new self($data); + } + + public function count() + { + return count($this->data); + } + + public function getIterator() + { + return new \ArrayIterator($this->data); + } + + public function toArray() + { + return $this->data; + } + + /** + * Removes all key value pairs + * + * @return Collection + */ + public function clear() + { + $this->data = array(); + + return $this; + } + + /** + * Get all or a subset of matching key value pairs + * + * @param array $keys Pass an array of keys to retrieve only a subset of key value pairs + * + * @return array Returns an array of all matching key value pairs + */ + public function getAll(array $keys = null) + { + return $keys ? array_intersect_key($this->data, array_flip($keys)) : $this->data; + } + + /** + * Get a specific key value. + * + * @param string $key Key to retrieve. + * + * @return mixed|null Value of the key or NULL + */ + public function get($key) + { + return isset($this->data[$key]) ? $this->data[$key] : null; + } + + /** + * Set a key value pair + * + * @param string $key Key to set + * @param mixed $value Value to set + * + * @return Collection Returns a reference to the object + */ + public function set($key, $value) + { + $this->data[$key] = $value; + + return $this; + } + + /** + * Add a value to a key. If a key of the same name has already been added, the key value will be converted into an + * array and the new value will be pushed to the end of the array. + * + * @param string $key Key to add + * @param mixed $value Value to add to the key + * + * @return Collection Returns a reference to the object. + */ + public function add($key, $value) + { + if (!array_key_exists($key, $this->data)) { + $this->data[$key] = $value; + } elseif (is_array($this->data[$key])) { + $this->data[$key][] = $value; + } else { + $this->data[$key] = array($this->data[$key], $value); + } + + return $this; + } + + /** + * Remove a specific key value pair + * + * @param string $key A key to remove + * + * @return Collection + */ + public function remove($key) + { + unset($this->data[$key]); + + return $this; + } + + /** + * Get all keys in the collection + * + * @return array + */ + public function getKeys() + { + return array_keys($this->data); + } + + /** + * Returns whether or not the specified key is present. + * + * @param string $key The key for which to check the existence. + * + * @return bool + */ + public function hasKey($key) + { + return array_key_exists($key, $this->data); + } + + /** + * Case insensitive search the keys in the collection + * + * @param string $key Key to search for + * + * @return bool|string Returns false if not found, otherwise returns the key + */ + public function keySearch($key) + { + foreach (array_keys($this->data) as $k) { + if (!strcasecmp($k, $key)) { + return $k; + } + } + + return false; + } + + /** + * Checks if any keys contains a certain value + * + * @param string $value Value to search for + * + * @return mixed Returns the key if the value was found FALSE if the value was not found. + */ + public function hasValue($value) + { + return array_search($value, $this->data); + } + + /** + * Replace the data of the object with the value of an array + * + * @param array $data Associative array of data + * + * @return Collection Returns a reference to the object + */ + public function replace(array $data) + { + $this->data = $data; + + return $this; + } + + /** + * Add and merge in a Collection or array of key value pair data. + * + * @param Collection|array $data Associative array of key value pair data + * + * @return Collection Returns a reference to the object. + */ + public function merge($data) + { + foreach ($data as $key => $value) { + $this->add($key, $value); + } + + return $this; + } + + /** + * Over write key value pairs in this collection with all of the data from an array or collection. + * + * @param array|\Traversable $data Values to override over this config + * + * @return self + */ + public function overwriteWith($data) + { + if (is_array($data)) { + $this->data = $data + $this->data; + } elseif ($data instanceof Collection) { + $this->data = $data->toArray() + $this->data; + } else { + foreach ($data as $key => $value) { + $this->data[$key] = $value; + } + } + + return $this; + } + + /** + * Returns a Collection containing all the elements of the collection after applying the callback function to each + * one. The Closure should accept three parameters: (string) $key, (string) $value, (array) $context and return a + * modified value + * + * @param \Closure $closure Closure to apply + * @param array $context Context to pass to the closure + * @param bool $static Set to TRUE to use the same class as the return rather than returning a Collection + * + * @return Collection + */ + public function map(\Closure $closure, array $context = array(), $static = true) + { + $collection = $static ? new static() : new self(); + foreach ($this as $key => $value) { + $collection->add($key, $closure($key, $value, $context)); + } + + return $collection; + } + + /** + * Iterates over each key value pair in the collection passing them to the Closure. If the Closure function returns + * true, the current value from input is returned into the result Collection. The Closure must accept three + * parameters: (string) $key, (string) $value and return Boolean TRUE or FALSE for each value. + * + * @param \Closure $closure Closure evaluation function + * @param bool $static Set to TRUE to use the same class as the return rather than returning a Collection + * + * @return Collection + */ + public function filter(\Closure $closure, $static = true) + { + $collection = ($static) ? new static() : new self(); + foreach ($this->data as $key => $value) { + if ($closure($key, $value)) { + $collection->add($key, $value); + } + } + + return $collection; + } + + public function offsetExists($offset) + { + return isset($this->data[$offset]); + } + + public function offsetGet($offset) + { + return isset($this->data[$offset]) ? $this->data[$offset] : null; + } + + public function offsetSet($offset, $value) + { + $this->data[$offset] = $value; + } + + public function offsetUnset($offset) + { + unset($this->data[$offset]); + } + + /** + * Set a value into a nested array key. Keys will be created as needed to set the value. + * + * @param string $path Path to set + * @param mixed $value Value to set at the key + * + * @return self + * @throws RuntimeException when trying to setPath using a nested path that travels through a scalar value + */ + public function setPath($path, $value) + { + $current =& $this->data; + $queue = explode('/', $path); + while (null !== ($key = array_shift($queue))) { + if (!is_array($current)) { + throw new RuntimeException("Trying to setPath {$path}, but {$key} is set and is not an array"); + } elseif (!$queue) { + $current[$key] = $value; + } elseif (isset($current[$key])) { + $current =& $current[$key]; + } else { + $current[$key] = array(); + $current =& $current[$key]; + } + } + + return $this; + } + + /** + * Gets a value from the collection using an array path (e.g. foo/baz/bar would retrieve bar from two nested arrays) + * Allows for wildcard searches which recursively combine matches up to the level at which the wildcard occurs. This + * can be useful for accepting any key of a sub-array and combining matching keys from each diverging path. + * + * @param string $path Path to traverse and retrieve a value from + * @param string $separator Character used to add depth to the search + * @param mixed $data Optional data to descend into (used when wildcards are encountered) + * + * @return mixed|null + */ + public function getPath($path, $separator = '/', $data = null) + { + if ($data === null) { + $data =& $this->data; + } + + $path = is_array($path) ? $path : explode($separator, $path); + while (null !== ($part = array_shift($path))) { + if (!is_array($data)) { + return null; + } elseif (isset($data[$part])) { + $data =& $data[$part]; + } elseif ($part != '*') { + return null; + } else { + // Perform a wildcard search by diverging and merging paths + $result = array(); + foreach ($data as $value) { + if (!$path) { + $result = array_merge_recursive($result, (array) $value); + } elseif (null !== ($test = $this->getPath($path, $separator, $value))) { + $result = array_merge_recursive($result, (array) $test); + } + } + return $result; + } + } + + return $data; + } + + /** + * Inject configuration settings into an input string + * + * @param string $input Input to inject + * + * @return string + * @deprecated + */ + public function inject($input) + { + Version::warn(__METHOD__ . ' is deprecated'); + $replace = array(); + foreach ($this->data as $key => $val) { + $replace['{' . $key . '}'] = $val; + } + + return strtr($input, $replace); + } +} diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Event.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Event.php new file mode 100644 index 00000000000..fad76a9b817 --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Event.php @@ -0,0 +1,52 @@ +<?php + +namespace Guzzle\Common; + +use Symfony\Component\EventDispatcher\Event as SymfonyEvent; + +/** + * Default event for Guzzle notifications + */ +class Event extends SymfonyEvent implements ToArrayInterface, \ArrayAccess, \IteratorAggregate +{ + /** @var array */ + private $context; + + /** + * @param array $context Contextual information + */ + public function __construct(array $context = array()) + { + $this->context = $context; + } + + public function getIterator() + { + return new \ArrayIterator($this->context); + } + + public function offsetGet($offset) + { + return isset($this->context[$offset]) ? $this->context[$offset] : null; + } + + public function offsetSet($offset, $value) + { + $this->context[$offset] = $value; + } + + public function offsetExists($offset) + { + return isset($this->context[$offset]); + } + + public function offsetUnset($offset) + { + unset($this->context[$offset]); + } + + public function toArray() + { + return $this->context; + } +} diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/BadMethodCallException.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/BadMethodCallException.php new file mode 100644 index 00000000000..08d1c7256d7 --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/BadMethodCallException.php @@ -0,0 +1,5 @@ +<?php + +namespace Guzzle\Common\Exception; + +class BadMethodCallException extends \BadMethodCallException implements GuzzleException {} diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/ExceptionCollection.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/ExceptionCollection.php new file mode 100644 index 00000000000..185d05cddac --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/ExceptionCollection.php @@ -0,0 +1,85 @@ +<?php + +namespace Guzzle\Common\Exception; + +/** + * Collection of exceptions + */ +class ExceptionCollection extends \Exception implements GuzzleException, \IteratorAggregate, \Countable +{ + /** @var array Array of Exceptions */ + protected $exceptions = array(); + + /** + * Set all of the exceptions + * + * @param array $exceptions Array of exceptions + * + * @return self + */ + public function setExceptions(array $exceptions) + { + $this->exceptions = array(); + foreach ($exceptions as $exception) { + $this->add($exception); + } + + return $this; + } + + /** + * Add exceptions to the collection + * + * @param ExceptionCollection|\Exception $e Exception to add + * + * @return ExceptionCollection; + */ + public function add($e) + { + if ($this->message) { + $this->message .= "\n"; + } + + if ($e instanceof self) { + $this->message .= '(' . get_class($e) . ")"; + foreach (explode("\n", $e->getMessage()) as $message) { + $this->message .= "\n {$message}"; + } + } elseif ($e instanceof \Exception) { + $this->exceptions[] = $e; + $this->message .= '(' . get_class($e) . ') ' . $e->getMessage(); + } + + return $this; + } + + /** + * Get the total number of request exceptions + * + * @return int + */ + public function count() + { + return count($this->exceptions); + } + + /** + * Allows array-like iteration over the request exceptions + * + * @return \ArrayIterator + */ + public function getIterator() + { + return new \ArrayIterator($this->exceptions); + } + + /** + * Get the first exception in the collection + * + * @return \Exception + */ + public function getFirst() + { + return $this->exceptions ? $this->exceptions[0] : null; + } +} diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/GuzzleException.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/GuzzleException.php new file mode 100644 index 00000000000..458e6f2ea16 --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/GuzzleException.php @@ -0,0 +1,8 @@ +<?php + +namespace Guzzle\Common\Exception; + +/** + * Guzzle exception + */ +interface GuzzleException {} diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/InvalidArgumentException.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/InvalidArgumentException.php new file mode 100644 index 00000000000..ae674be8790 --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/InvalidArgumentException.php @@ -0,0 +1,5 @@ +<?php + +namespace Guzzle\Common\Exception; + +class InvalidArgumentException extends \InvalidArgumentException implements GuzzleException {} diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/RuntimeException.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/RuntimeException.php new file mode 100644 index 00000000000..9254094f3e3 --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/RuntimeException.php @@ -0,0 +1,5 @@ +<?php + +namespace Guzzle\Common\Exception; + +class RuntimeException extends \RuntimeException implements GuzzleException {} diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/UnexpectedValueException.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/UnexpectedValueException.php new file mode 100644 index 00000000000..843c0179ebf --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Exception/UnexpectedValueException.php @@ -0,0 +1,5 @@ +<?php + +namespace Guzzle\Common\Exception; + +class UnexpectedValueException extends \UnexpectedValueException implements GuzzleException {} diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/FromConfigInterface.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/FromConfigInterface.php new file mode 100644 index 00000000000..c8b1317c446 --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/FromConfigInterface.php @@ -0,0 +1,18 @@ +<?php + +namespace Guzzle\Common; + +/** + * Interfaces that adds a factory method which is used to instantiate a class from an array of configuration options. + */ +interface FromConfigInterface +{ + /** + * Static factory method used to turn an array or collection of configuration data into an instantiated object. + * + * @param array|Collection $config Configuration data + * + * @return FromConfigInterface + */ + public static function factory($config = array()); +} diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/HasDispatcherInterface.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/HasDispatcherInterface.php new file mode 100644 index 00000000000..75727ed9e25 --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/HasDispatcherInterface.php @@ -0,0 +1,52 @@ +<?php + +namespace Guzzle\Common; + +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * Holds an event dispatcher + */ +interface HasDispatcherInterface +{ + /** + * Get a list of all of the events emitted from the class + * + * @return array + */ + public static function getAllEvents(); + + /** + * Set the EventDispatcher of the request + * + * @param EventDispatcherInterface $eventDispatcher + * + * @return self + */ + public function setEventDispatcher(EventDispatcherInterface $eventDispatcher); + + /** + * Get the EventDispatcher of the request + * + * @return EventDispatcherInterface + */ + public function getEventDispatcher(); + + /** + * Helper to dispatch Guzzle events and set the event name on the event + * + * @param string $eventName Name of the event to dispatch + * @param array $context Context of the event + */ + public function dispatch($eventName, array $context = array()); + + /** + * Add an event subscriber to the dispatcher + * + * @param EventSubscriberInterface $subscriber Event subscriber + * + * @return self + */ + public function addSubscriber(EventSubscriberInterface $subscriber); +} diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/ToArrayInterface.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/ToArrayInterface.php new file mode 100644 index 00000000000..245328c1b3a --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/ToArrayInterface.php @@ -0,0 +1,16 @@ +<?php + +namespace Guzzle\Common; + +/** + * An object that can be represented as an array + */ +interface ToArrayInterface +{ + /** + * Get the array representation of an object + * + * @return array + */ + public function toArray(); +} diff --git a/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Version.php b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Version.php new file mode 100644 index 00000000000..9e394659b71 --- /dev/null +++ b/apps/files_external/3rdparty/aws-sdk-php/Guzzle/Common/Version.php @@ -0,0 +1,29 @@ +<?php + +namespace Guzzle\Common; + +/** + * Guzzle version information + */ +class Version +{ + const VERSION = '3.7.0'; + + /** + * @var bool Set this value to true to enable warnings for deprecated functionality use. This should be on in your + * unit tests, but probably not in production. + */ + public static $emitWarnings = false; + + /** + * Emit a deprecation warning + * + * @param string $message Warning message + */ + public static function warn($message) + { + if (self::$emitWarnings) { + trigger_error('Deprecation warning: ' . $message, E_USER_DEPRECATED); + } + } +} |