diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-01-07 13:06:14 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-01-07 13:06:14 +0100 |
| commit | 7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8 (patch) | |
| tree | f7453d7dd5cbaaab246e23810b02d3edf1e451be /srcs/wordpress/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php | |
| parent | c59bdcf77c50cbe89b4a93782cdd6d9e7532080e (diff) | |
| download | ft_server-7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8.tar.gz ft_server-7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8.tar.bz2 ft_server-7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8.zip | |
Added wordpress
Diffstat (limited to 'srcs/wordpress/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php')
| -rw-r--r-- | srcs/wordpress/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/srcs/wordpress/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php b/srcs/wordpress/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php new file mode 100644 index 0000000..2c97893 --- /dev/null +++ b/srcs/wordpress/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php @@ -0,0 +1,103 @@ +<?php +/** + * Case-insensitive dictionary, suitable for HTTP headers + * + * @package Requests + * @subpackage Utilities + */ + +/** + * Case-insensitive dictionary, suitable for HTTP headers + * + * @package Requests + * @subpackage Utilities + */ +class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, IteratorAggregate { + /** + * Actual item data + * + * @var array + */ + protected $data = array(); + + /** + * Creates a case insensitive dictionary. + * + * @param array $data Dictionary/map to convert to case-insensitive + */ + public function __construct(array $data = array()) { + foreach ($data as $key => $value) { + $this->offsetSet($key, $value); + } + } + + /** + * Check if the given item exists + * + * @param string $key Item key + * @return boolean Does the item exist? + */ + public function offsetExists($key) { + $key = strtolower($key); + return isset($this->data[$key]); + } + + /** + * Get the value for the item + * + * @param string $key Item key + * @return string Item value + */ + public function offsetGet($key) { + $key = strtolower($key); + if (!isset($this->data[$key])) { + return null; + } + + return $this->data[$key]; + } + + /** + * Set the given item + * + * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`) + * + * @param string $key Item name + * @param string $value Item value + */ + public function offsetSet($key, $value) { + if ($key === null) { + throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset'); + } + + $key = strtolower($key); + $this->data[$key] = $value; + } + + /** + * Unset the given header + * + * @param string $key + */ + public function offsetUnset($key) { + unset($this->data[strtolower($key)]); + } + + /** + * Get an iterator for the data + * + * @return ArrayIterator + */ + public function getIterator() { + return new ArrayIterator($this->data); + } + + /** + * Get the headers as an array + * + * @return array Header data + */ + public function getAll() { + return $this->data; + } +} |
