From 7086111ad4dd997e12a3220e1ee60c9b9bcf0bb8 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 7 Jan 2020 13:06:14 +0100 Subject: Added wordpress --- .../Requests/Utility/CaseInsensitiveDictionary.php | 103 +++++++++++++++++++++ .../Requests/Utility/FilteredIterator.php | 45 +++++++++ 2 files changed, 148 insertions(+) create mode 100644 srcs/wordpress/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php create mode 100644 srcs/wordpress/wp-includes/Requests/Utility/FilteredIterator.php (limited to 'srcs/wordpress/wp-includes/Requests/Utility') 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 @@ + $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; + } +} diff --git a/srcs/wordpress/wp-includes/Requests/Utility/FilteredIterator.php b/srcs/wordpress/wp-includes/Requests/Utility/FilteredIterator.php new file mode 100644 index 0000000..76a29e7 --- /dev/null +++ b/srcs/wordpress/wp-includes/Requests/Utility/FilteredIterator.php @@ -0,0 +1,45 @@ +callback = $callback; + } + + /** + * Get the current item's value after filtering + * + * @return string + */ + public function current() { + $value = parent::current(); + $value = call_user_func($this->callback, $value); + return $value; + } +} -- cgit