public static function get($target, $key, $default = null)
    {
        if (is_null($key) || !is_object($target)) {
            return self::value($default);
        }

        if (!is_array($key)) {
            if (isset($target->{$key}) || property_exists($target, $key)) {
                return $target->{$key};
            }

            $keys = explode('.', $key);
        } else {
            $keys = $key;
        }
        foreach ($keys as $segment) {
            if (is_object($target) && isset($target->{$segment})) {
                $target = $target->{$segment};
            } else {
                return self::value($default);
            }
        }

        return $target;
    }
public static function get($target, $key, $default = null)
    {
        if (is_null($key) || !is_object($target)) {
            return self::value($default);
        }

        if (!is_array($key)) {
            if (isset($target->{$key}) || property_exists($target, $key)) {
                return $target->{$key};
            }

            $keys = explode('.', $key);
        } else {
            $keys = $key;
        }
        foreach ($keys as $segment) {
            if (is_object($target) && isset($target->{$segment})) {
                $target = $target->{$segment};
            } else {
                return self::value($default);
            }
        }

        return $target;
    }
public static function get ( $ target , $ key , $ default = null ) { if ( is_null ( $ key ) || ! is_object ( $ target ) ) { return self :: value ( $ default ) ; } if ( ! is_array ( $ key ) ) { if ( isset ( $ target -> { $ key } ) || property_exists ( $ target , $ key ) ) { return $ target -> { $ key } ; } $ keys = explode ( '.' , $ key ) ; } else { $ keys = $ key ; } foreach ( $ keys as $ segment ) { if ( is_object ( $ target ) && isset ( $ target -> { $ segment } ) ) { $ target = $ target -> { $ segment } ; } else { return self :: value ( $ default ) ; } } return $ target ; }
Get an item from an array or object using "dot" notation.

@param  mixed        $target
@param  string|array $key
@param  mixed        $default

@return mixed
Get an item from an array or object using dot notation .