public function get($key)
    {
        // check if a key has been passed
        if (is_null($key)) {
            throw new NullPointerException('Passed key is null');
        }
        // check if a primitive datatype is passed
        if (is_integer($key) || is_string($key) || is_double($key) || is_bool($key)) {
            // return the value for the passed key, if it exists
            if (array_key_exists($key, $this->items) && !$this->isTimedOut($key)) {
                // item is available and NOT timed out
                return $this->items[$key];
            } elseif (array_key_exists($key, $this->items) && $this->isTimedOut($key)) {
                // item is available, but timed out
                return;
            } else {
                // item is generally not available
                throw new IndexOutOfBoundsException(sprintf('Index %s out of bounds', $key));
            }
        }
        // check if an object is passed
        if (is_object($key)) {
            if ($key instanceof String) {
                $newKey = $key->stringValue();
            } elseif ($key instanceof Float) {
                $newKey = $key->floatValue();
            } elseif ($key instanceof Integer) {
                $newKey = $key->intValue();
            } elseif ($key instanceof Boolean) {
                $newKey = $key->booleanValue();
            } elseif (method_exists($key, '__toString')) {
                $newKey = $key->__toString();
            } else {
                throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method');
            }
            // return the value for the passed key, if it exists
            if (array_key_exists($newKey, $this->items) && !$this->isTimedOut($newKey)) {
                // item is available and NOT timed out
                return $this->items[$newKey];
            } elseif (array_key_exists($newKey, $this->items) && $this->isTimedOut($newKey)) {
                // item is available, but timed out
                return;
            } else {
                // item is generally not available
                throw new IndexOutOfBoundsException(sprintf('Index %s out of bounds', $newKey));
            }
        }
        throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method');
    }
public function get($key)
    {
        // check if a key has been passed
        if (is_null($key)) {
            throw new NullPointerException('Passed key is null');
        }
        // check if a primitive datatype is passed
        if (is_integer($key) || is_string($key) || is_double($key) || is_bool($key)) {
            // return the value for the passed key, if it exists
            if (array_key_exists($key, $this->items) && !$this->isTimedOut($key)) {
                // item is available and NOT timed out
                return $this->items[$key];
            } elseif (array_key_exists($key, $this->items) && $this->isTimedOut($key)) {
                // item is available, but timed out
                return;
            } else {
                // item is generally not available
                throw new IndexOutOfBoundsException(sprintf('Index %s out of bounds', $key));
            }
        }
        // check if an object is passed
        if (is_object($key)) {
            if ($key instanceof String) {
                $newKey = $key->stringValue();
            } elseif ($key instanceof Float) {
                $newKey = $key->floatValue();
            } elseif ($key instanceof Integer) {
                $newKey = $key->intValue();
            } elseif ($key instanceof Boolean) {
                $newKey = $key->booleanValue();
            } elseif (method_exists($key, '__toString')) {
                $newKey = $key->__toString();
            } else {
                throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method');
            }
            // return the value for the passed key, if it exists
            if (array_key_exists($newKey, $this->items) && !$this->isTimedOut($newKey)) {
                // item is available and NOT timed out
                return $this->items[$newKey];
            } elseif (array_key_exists($newKey, $this->items) && $this->isTimedOut($newKey)) {
                // item is available, but timed out
                return;
            } else {
                // item is generally not available
                throw new IndexOutOfBoundsException(sprintf('Index %s out of bounds', $newKey));
            }
        }
        throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method');
    }
public function get ( $ key ) { // check if a key has been passed if ( is_null ( $ key ) ) { throw new NullPointerException ( 'Passed key is null' ) ; } // check if a primitive datatype is passed if ( is_integer ( $ key ) || is_string ( $ key ) || is_double ( $ key ) || is_bool ( $ key ) ) { // return the value for the passed key, if it exists if ( array_key_exists ( $ key , $ this -> items ) && ! $ this -> isTimedOut ( $ key ) ) { // item is available and NOT timed out return $ this -> items [ $ key ] ; } elseif ( array_key_exists ( $ key , $ this -> items ) && $ this -> isTimedOut ( $ key ) ) { // item is available, but timed out return ; } else { // item is generally not available throw new IndexOutOfBoundsException ( sprintf ( 'Index %s out of bounds' , $ key ) ) ; } } // check if an object is passed if ( is_object ( $ key ) ) { if ( $ key instanceof String ) { $ newKey = $ key -> stringValue ( ) ; } elseif ( $ key instanceof Float ) { $ newKey = $ key -> floatValue ( ) ; } elseif ( $ key instanceof Integer ) { $ newKey = $ key -> intValue ( ) ; } elseif ( $ key instanceof Boolean ) { $ newKey = $ key -> booleanValue ( ) ; } elseif ( method_exists ( $ key , '__toString' ) ) { $ newKey = $ key -> __toString ( ) ; } else { throw new InvalidKeyException ( 'Passed key has to be a primitive datatype or has to implement the __toString() method' ) ; } // return the value for the passed key, if it exists if ( array_key_exists ( $ newKey , $ this -> items ) && ! $ this -> isTimedOut ( $ newKey ) ) { // item is available and NOT timed out return $ this -> items [ $ newKey ] ; } elseif ( array_key_exists ( $ newKey , $ this -> items ) && $ this -> isTimedOut ( $ newKey ) ) { // item is available, but timed out return ; } else { // item is generally not available throw new IndexOutOfBoundsException ( sprintf ( 'Index %s out of bounds' , $ newKey ) ) ; } } throw new InvalidKeyException ( 'Passed key has to be a primitive datatype or has to implement the __toString() method' ) ; }
This method returns the element with the passed key
from the Collection.

@param mixed $key Holds the key of the element to return

@return mixed The requested element
@throws \AppserverIo\Collections\InvalidKeyException Is thrown if the passed key is NOT an integer
@throws \AppserverIo\Lang\NullPointerException Is thrown if the passed key OR value are NULL
@throws \AppserverIo\Collections\IndexOutOfBoundsException Is thrown if no element with the passed key exists in the Collection
@see \AppserverIo\Collections\CollectionInterface::get($key)
This method returns the element with the passed key from the Collection .