src/CloudTrail/LogFileIterator.php
private function applyRegexFilter(
        $objectsIterator,
        $logKeyPrefix,
        $candidatePrefix
    ) {
        // If the prefix and candidate prefix are not the same, then there were
        // WILDCARDs.
        if ($logKeyPrefix !== $candidatePrefix) {
            // Turn the candidate prefix into a regex by trimming and
            // converting WILDCARDs to regex notation.
            $regex = rtrim($candidatePrefix, '/' . self::PREFIX_WILDCARD) . '/';
            $regex = strtr($regex, [self::PREFIX_WILDCARD => '[^/]+']);

            // After trimming WILDCARDs or the end, if the regex is the same as
            // the prefix, then no regex is needed.
            if ($logKeyPrefix !== $regex) {
                // Apply a regex filter iterator to remove files that don't
                // match the provided options.
                $objectsIterator = new \CallbackFilterIterator(
                    $objectsIterator,
                    function ($object) use ($regex) {
                        return preg_match("#{$regex}#", $object['Key']);
                    }
                );
            }
        }

        return $objectsIterator;
    }
private function applyRegexFilter(
        $objectsIterator,
        $logKeyPrefix,
        $candidatePrefix
    ) {
        // If the prefix and candidate prefix are not the same, then there were
        // WILDCARDs.
        if ($logKeyPrefix !== $candidatePrefix) {
            // Turn the candidate prefix into a regex by trimming and
            // converting WILDCARDs to regex notation.
            $regex = rtrim($candidatePrefix, '/' . self::PREFIX_WILDCARD) . '/';
            $regex = strtr($regex, [self::PREFIX_WILDCARD => '[^/]+']);

            // After trimming WILDCARDs or the end, if the regex is the same as
            // the prefix, then no regex is needed.
            if ($logKeyPrefix !== $regex) {
                // Apply a regex filter iterator to remove files that don't
                // match the provided options.
                $objectsIterator = new \CallbackFilterIterator(
                    $objectsIterator,
                    function ($object) use ($regex) {
                        return preg_match("#{$regex}#", $object['Key']);
                    }
                );
            }
        }

        return $objectsIterator;
    }
private function applyRegexFilter ( $ objectsIterator , $ logKeyPrefix , $ candidatePrefix ) { // If the prefix and candidate prefix are not the same, then there were // WILDCARDs. if ( $ logKeyPrefix !== $ candidatePrefix ) { // Turn the candidate prefix into a regex by trimming and // converting WILDCARDs to regex notation. $ regex = rtrim ( $ candidatePrefix , '/' . self :: PREFIX_WILDCARD ) . '/' ; $ regex = strtr ( $ regex , [ self :: PREFIX_WILDCARD => '[^/]+' ] ) ; // After trimming WILDCARDs or the end, if the regex is the same as // the prefix, then no regex is needed. if ( $ logKeyPrefix !== $ regex ) { // Apply a regex filter iterator to remove files that don't // match the provided options. $ objectsIterator = new \ CallbackFilterIterator ( $ objectsIterator , function ( $ object ) use ( $ regex ) { return preg_match ( "#{$regex}#" , $ object [ 'Key' ] ) ; } ) ; } } return $ objectsIterator ; }
Applies a regex iterator filter that limits the ListObjects result set
based on the provided options.

@param \Iterator $objectsIterator
@param string    $logKeyPrefix
@param string    $candidatePrefix

@return \Iterator
Applies a regex iterator filter that limits the ListObjects result set based on the provided options .