src/GeneratorCollection.php
private function accessKey($mixed, $key, $givenKey = null)
    {
        // Handle callable keys, just pass in the mixed and return the result.
        if (is_callable($key)) {
            return $key($mixed, $givenKey);
        }

        // If it's a string, an array, or accessible through []
        if (is_string($mixed) || is_array($mixed) || $mixed instanceof ArrayAccess) {
            return $mixed[$key];
        }

        // If it's an object
        if (is_object($mixed)) {
            return $mixed->{$key};
        }

        // Give up
        throw new InvalidArgumentException('Invalid object type provided, cannot access key.');
    }
private function accessKey($mixed, $key, $givenKey = null)
    {
        // Handle callable keys, just pass in the mixed and return the result.
        if (is_callable($key)) {
            return $key($mixed, $givenKey);
        }

        // If it's a string, an array, or accessible through []
        if (is_string($mixed) || is_array($mixed) || $mixed instanceof ArrayAccess) {
            return $mixed[$key];
        }

        // If it's an object
        if (is_object($mixed)) {
            return $mixed->{$key};
        }

        // Give up
        throw new InvalidArgumentException('Invalid object type provided, cannot access key.');
    }
private function accessKey ( $ mixed , $ key , $ givenKey = null ) { // Handle callable keys, just pass in the mixed and return the result. if ( is_callable ( $ key ) ) { return $ key ( $ mixed , $ givenKey ) ; } // If it's a string, an array, or accessible through [] if ( is_string ( $ mixed ) || is_array ( $ mixed ) || $ mixed instanceof ArrayAccess ) { return $ mixed [ $ key ] ; } // If it's an object if ( is_object ( $ mixed ) ) { return $ mixed -> { $ key } ; } // Give up throw new InvalidArgumentException ( 'Invalid object type provided, cannot access key.' ) ; }
Get a value from a mixed key
@param mixed $mixed
@param mixed $key
@param null|string $givenKey
@return mixed
@throws \InvalidArgumentException
Get a value from a mixed key