File "CaseInsensitiveDictionary.php"

Full path: /home/kosmetik/public_html/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php
File size: 1.1 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php

class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, IteratorAggregate
{
    protected $data = array();
    public function __construct(array $data = array())
    {
        foreach ($data as $key => $value) {
            $this->offsetSet($key, $value);
        }
    }
    public function offsetExists($key)
    {
        $key = strtolower($key);
        return isset($this->data[$key]);
    }
    public function offsetGet($key)
    {
        $key = strtolower($key);
        if (!isset($this->data[$key])) {
            return null;
        }
        return $this->data[$key];
    }
    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;
    }
    public function offsetUnset($key)
    {
        unset($this->data[strtolower($key)]);
    }
    public function getIterator()
    {
        return new ArrayIterator($this->data);
    }
    public function getAll()
    {
        return $this->data;
    }
}