for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
//----------------------------------------------------------------------
//
// Copyright (C) 2015 Artem Rodygin
// You should have received a copy of the MIT License along with
// this file. If not, see <http://opensource.org/licenses/MIT>.
namespace Dictionary;
/**
* Abstract static dictionary of key/value pairs.
*/
abstract class StaticDictionary implements StaticDictionaryInterface
{
/** @var array Dictionary values (to be overloaded). */
protected static $dictionary = [];
* {@inheritdoc}
public static function all()
return static::$dictionary;
}
public static function get($key)
if (array_key_exists($key, static::$dictionary)) {
return static::$dictionary[$key];
else {
return static::FALLBACK === null ? null : static::$dictionary[static::FALLBACK];
public static function has($key)
return array_key_exists($key, static::$dictionary);
public static function find($value)
$key = array_search($value, static::$dictionary);
return $key === false ? static::FALLBACK : $key;
public static function keys()
return array_keys(static::$dictionary);
public static function values()
return array_values(static::$dictionary);