src/Kisma/Core/Utility/Option.php
public static function get( &$options = array(), $key, $defaultValue = null, $unsetValue = false, $emptyStringIsNull = false )
    {
        //	Get many?
        if ( is_array( $key ) )
        {
            return static::getMany( $options, $key, $defaultValue, $unsetValue );
        }

        $_originalKey = $key;

        //	Set the default value
        $_newValue = $defaultValue;

        //	Now a deeper search
        $key = static::_cleanKey( $key );

        //	Get array value if it exists
        if ( is_array( $options ) || $options instanceof \ArrayAccess )
        {
            //	Check for the original key too
            if ( !isset( $options[$key] ) && isset( $options[$_originalKey] ) )
            {
                $key = $_originalKey;
            }

            if ( isset( $options[$key] ) )
            {
                $_newValue = $options[$key];

                if ( false !== $unsetValue )
                {
                    unset( $options[$key] );
                }

                return $emptyStringIsNull && empty( $_newValue ) ? null : $_newValue;
            }
        }

        if ( is_object( $options ) )
        {
            if ( !property_exists( $options, $key ) && property_exists( $options, $_originalKey ) )
            {
                $key = $_originalKey;
            }

            if ( isset( $options->{$key} ) )
            {
                $_newValue = $options->{$key};

                if ( false !== $unsetValue )
                {
                    unset( $options->{$key} );
                }

                return $emptyStringIsNull && empty( $_newValue ) ? null : $_newValue;
            }
            else if ( method_exists( $options, 'get' . $key ) )
            {
                $_getter = 'get' . Inflector::deneutralize( $key );
                $_setter = 'set' . Inflector::deneutralize( $key );

                $_newValue = $options->{$_getter}();

                if ( false !== $unsetValue && method_exists( $options, $_setter ) )
                {
                    $options->{$_setter}( null );
                }
            }
        }

        //	Return the default...
        return $emptyStringIsNull && empty( $_newValue ) ? null : $_newValue;
    }
public static function get( &$options = array(), $key, $defaultValue = null, $unsetValue = false, $emptyStringIsNull = false )
    {
        //	Get many?
        if ( is_array( $key ) )
        {
            return static::getMany( $options, $key, $defaultValue, $unsetValue );
        }

        $_originalKey = $key;

        //	Set the default value
        $_newValue = $defaultValue;

        //	Now a deeper search
        $key = static::_cleanKey( $key );

        //	Get array value if it exists
        if ( is_array( $options ) || $options instanceof \ArrayAccess )
        {
            //	Check for the original key too
            if ( !isset( $options[$key] ) && isset( $options[$_originalKey] ) )
            {
                $key = $_originalKey;
            }

            if ( isset( $options[$key] ) )
            {
                $_newValue = $options[$key];

                if ( false !== $unsetValue )
                {
                    unset( $options[$key] );
                }

                return $emptyStringIsNull && empty( $_newValue ) ? null : $_newValue;
            }
        }

        if ( is_object( $options ) )
        {
            if ( !property_exists( $options, $key ) && property_exists( $options, $_originalKey ) )
            {
                $key = $_originalKey;
            }

            if ( isset( $options->{$key} ) )
            {
                $_newValue = $options->{$key};

                if ( false !== $unsetValue )
                {
                    unset( $options->{$key} );
                }

                return $emptyStringIsNull && empty( $_newValue ) ? null : $_newValue;
            }
            else if ( method_exists( $options, 'get' . $key ) )
            {
                $_getter = 'get' . Inflector::deneutralize( $key );
                $_setter = 'set' . Inflector::deneutralize( $key );

                $_newValue = $options->{$_getter}();

                if ( false !== $unsetValue && method_exists( $options, $_setter ) )
                {
                    $options->{$_setter}( null );
                }
            }
        }

        //	Return the default...
        return $emptyStringIsNull && empty( $_newValue ) ? null : $_newValue;
    }
public static function get ( & $ options = array ( ) , $ key , $ defaultValue = null , $ unsetValue = false , $ emptyStringIsNull = false ) { //	Get many? if ( is_array ( $ key ) ) { return static :: getMany ( $ options , $ key , $ defaultValue , $ unsetValue ) ; } $ _originalKey = $ key ; //	Set the default value $ _newValue = $ defaultValue ; //	Now a deeper search $ key = static :: _cleanKey ( $ key ) ; //	Get array value if it exists if ( is_array ( $ options ) || $ options instanceof \ ArrayAccess ) { //	Check for the original key too if ( ! isset ( $ options [ $ key ] ) && isset ( $ options [ $ _originalKey ] ) ) { $ key = $ _originalKey ; } if ( isset ( $ options [ $ key ] ) ) { $ _newValue = $ options [ $ key ] ; if ( false !== $ unsetValue ) { unset ( $ options [ $ key ] ) ; } return $ emptyStringIsNull && empty ( $ _newValue ) ? null : $ _newValue ; } } if ( is_object ( $ options ) ) { if ( ! property_exists ( $ options , $ key ) && property_exists ( $ options , $ _originalKey ) ) { $ key = $ _originalKey ; } if ( isset ( $ options -> { $ key } ) ) { $ _newValue = $ options -> { $ key } ; if ( false !== $ unsetValue ) { unset ( $ options -> { $ key } ) ; } return $ emptyStringIsNull && empty ( $ _newValue ) ? null : $ _newValue ; } else if ( method_exists ( $ options , 'get' . $ key ) ) { $ _getter = 'get' . Inflector :: deneutralize ( $ key ) ; $ _setter = 'set' . Inflector :: deneutralize ( $ key ) ; $ _newValue = $ options -> { $ _getter } ( ) ; if ( false !== $ unsetValue && method_exists ( $ options , $ _setter ) ) { $ options -> { $ _setter } ( null ) ; } } } //	Return the default... return $ emptyStringIsNull && empty ( $ _newValue ) ? null : $ _newValue ; }
Retrieves an option from the given array.

$defaultValue is returned if $key is not found.
Can optionally delete $key from $options.

@param array|\ArrayAccess|object $options           An array or object from which to get $key's value
@param string                    $key               The array index or property to retrieve from $options
@param mixed                     $defaultValue      The value to return if $key is not found
@param boolean                   $unsetValue        If true, the $key will be removed from $options after
retrieval
@param bool                      $emptyStringIsNull If true, empty() values will always return as NULL

@return mixed
Retrieves an option from the given array .