Page MenuHomePhorge
Diviner Arcanist Tech Docs CaseInsensitiveArray

final class CaseInsensitiveArray
Arcanist Technical Documentation ()

A case-insensitive associative array.

This class represents an associative array in which the keys are considered to be case insensitive. This means that $array['key'] and $array['KEY'] will refer to the same array element.

$array = new CaseInsensitiveArray();

$array['key'] = 'value';
echo $array['KEY']; // 'value'

$array['kEy'] = 'foobar';
var_dump($array->toArray()); // array('key' => 'foobar')

Note that it is not possible to reuse case variants of a key. That is, if the array contains key xyz then it is not possible to use any of the following case variants as an array key: xyZ, xYz, xYZ, Xyz, XyZ, XYz, XYZ. In order to use a case variant as a key, it is necessary to first unset the original case variant.

$array = new CaseInsensitiveArray(array('key' => 'foo', 'KEY' => 'bar'));
var_dump($array->toArray()); // array('key' => 'bar')

$array['KEY'] = 'baz';
var_dump($array->toArray()); // array('key' => 'baz')

unset($array['key']);
$array['KEY'] = 'baz';
var_dump($array->toArray()); // array('KEY' => 'baz')

Methods

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

This method is not documented.
Parameters
$name
$value
Return
wild

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

Read the value of a class constant.

This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

public function __construct($data)

Construct a new array object.

Parameters
array$initial_value
Return
this//Implicit.//

public function toArray()
Inherited

This method is not documented.
Return
wild

public function count()
Inherited

This method is not documented.
Return
wild

public function offsetExists($key)

This method is not documented.
Parameters
$key
Return
wild

public function offsetGet($key)

This method is not documented.
Parameters
$key
Return
wild

public function offsetSet($key, $value)

This method is not documented.
Parameters
$key
$value
Return
wild

public function offsetUnset($key)

This method is not documented.
Parameters
$key
Return
wild

public function getKeys()

This method is not documented.
Return
wild

private function transformKey($key)

Transform an array key.

This method transforms an array key to be case-invariant. We could just call [[http://php.net/manual/en/function.strtolower.php | strtolower]] directly, but this method allows us to contain the key transformation logic within a single method, should it ever change.

Theoretically, we should be able to use any of the following functions for the purpose of key transformations:

Parameters
string$keyThe input key.
Return
stringThe transformed key.