public function getType($key, $type)
    {
        if (is_array($key))
        {
            $args = $key;
        }
        else
        {
            $args = func_get_args();
            $type = array_pop($args); // Type
        }
        $val = $this->dget($args);

        if ($val === null)
            throw new \OutOfRangeException("Key " . implode('.', $args) . " does not exist");

        $checker = $type instanceof Type ? $type : new Type($type, ['unstrict' => true]);
        try
        {
            $value = $checker->filter($val);
        }
        catch (\InvalidArgumentException $e)
        {
            throw new \DomainException("Key " . implode('.', $args) . " is not " . (string)$checker);
        }

        return $value;
    }
public function getType($key, $type)
    {
        if (is_array($key))
        {
            $args = $key;
        }
        else
        {
            $args = func_get_args();
            $type = array_pop($args); // Type
        }
        $val = $this->dget($args);

        if ($val === null)
            throw new \OutOfRangeException("Key " . implode('.', $args) . " does not exist");

        $checker = $type instanceof Type ? $type : new Type($type, ['unstrict' => true]);
        try
        {
            $value = $checker->filter($val);
        }
        catch (\InvalidArgumentException $e)
        {
            throw new \DomainException("Key " . implode('.', $args) . " is not " . (string)$checker);
        }

        return $value;
    }
public function getType ( $ key , $ type ) { if ( is_array ( $ key ) ) { $ args = $ key ; } else { $ args = func_get_args ( ) ; $ type = array_pop ( $ args ) ; // Type } $ val = $ this -> dget ( $ args ) ; if ( $ val === null ) throw new \ OutOfRangeException ( "Key " . implode ( '.' , $ args ) . " does not exist" ) ; $ checker = $ type instanceof Type ? $ type : new Type ( $ type , [ 'unstrict' => true ] ) ; try { $ value = $ checker -> filter ( $ val ) ; } catch ( \ InvalidArgumentException $ e ) { throw new \ DomainException ( "Key " . implode ( '.' , $ args ) . " is not " . ( string ) $ checker ) ; } return $ value ; }
Get a value cast to a specific type.
@param $key scalar The key to get. May be repeated to go deeper
@param $type The type (one of the constants in Type)
@return mixed The type as requested
Get a value cast to a specific type .