diff options
Diffstat (limited to 'SemanticMediaWiki/includes/SimpleDictionary.php')
-rw-r--r-- | SemanticMediaWiki/includes/SimpleDictionary.php | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/SemanticMediaWiki/includes/SimpleDictionary.php b/SemanticMediaWiki/includes/SimpleDictionary.php deleted file mode 100644 index 5caadafa..00000000 --- a/SemanticMediaWiki/includes/SimpleDictionary.php +++ /dev/null @@ -1,137 +0,0 @@ -<?php - -namespace SMW; - -use InvalidArgumentException; -use OutOfBoundsException; - -/** - * Class handling the implementation of a simple dictionary - * - * Implementing a dictionary (associative array, hash array) which is a - * collection of key, value pairs. - * - * @par Example: - * @code - * $dictionary = new SimpleDictionary( array( 'Foo' => 'Bar' ) ); - * - * $dictionary->has( 'Foo' ) returns true - * $dictionary->get( 'Foo' ) returns 'Bar' - * $dictionary->set( 'Foo', array( 'Lula', 'Bar') ) - * $dictionary->remove( 'Foo' ) - * @endcode - * - * @ingroup SMW - * - * @licence GNU GPL v2+ - * @since 1.9 - * - * @author mwjames - */ -class SimpleDictionary extends ObjectStorage implements ObjectDictionary { - - /** - * Returns whether a specific element is accessible - * - * @since 1.9 - * - * @param mixed $key - * - * @return boolean - * @throws InvalidArgumentException - */ - public function has( $key ) { - - if ( !( (string)$key === $key ) ) { - throw new InvalidArgumentException( 'The invoked key is not a string' ); - } - - return $this->contains( $key ); - } - - /** - * Adds a new element (key, value pair) to an existing collection - * - * @since 1.9 - * - * @param string $key - * @param mixed $value - * - * @return SimpleDictionary - * @throws InvalidArgumentException - */ - public function set( $key, $value ) { - - if ( !( (string)$key === $key ) ) { - throw new InvalidArgumentException( 'The invoked key is not a string' ); - } - - $this->attach( $key, $value ); - return $this; - } - - /** - * Returns a container value - * - * @since 1.9 - * - * @param string $key - * - * @return mixed - * @throws OutOfBoundsException - */ - public function get( $key ) { - - if ( !( $this->has( $key ) ) ) { - throw new OutOfBoundsException( "'{$key}' is unknown" ); - } - - return $this->lookup( $key ); - } - - /** - * Removes an element from a collection - * - * @since 1.9 - * - * @param string $key - * - * @return SimpleDictionary - * @throws InvalidArgumentException - */ - public function remove( $key ) { - - if ( !( (string)$key === $key ) ) { - throw new InvalidArgumentException( 'The invoked key is not a string' ); - } - - $this->detach( $key ); - return $this; - } - - /** - * Returns invoked array without conversion - * - * @since 1.9 - * - * @return array - */ - public function toArray() { - return $this->storage; - } - - /** - * Merges elements of one or more arrays together - * - * @since 1.9 - * - * @param array $mergeable - * - * @return SimpleDictionary - */ - public function merge( array $mergeable ) { - $this->storage = array_merge( $this->storage, $mergeable ); - return $this; - } - -} |