src/CloudTrail/LogFileIterator.php
private function buildListObjectsIterator(array $options)
    {
        // Extract and normalize the date values from the options
        $startDate = isset($options[self::START_DATE])
            ? $this->normalizeDateValue($options[self::START_DATE])
            : null;
        $endDate = isset($options[self::END_DATE])
            ? $this->normalizeDateValue($options[self::END_DATE])
            : null;

        // Determine the parts of the key prefix of the log files being read
        $parts = [
            'prefix' => isset($options[self::KEY_PREFIX])
                    ? $options[self::KEY_PREFIX]
                    : null,
            'account' => isset($options[self::ACCOUNT_ID])
                    ? $options[self::ACCOUNT_ID]
                    : self::PREFIX_WILDCARD,
            'region' => isset($options[self::LOG_REGION])
                    ? $options[self::LOG_REGION]
                    : self::PREFIX_WILDCARD,
            'date' => $this->determineDateForPrefix($startDate, $endDate),
        ];

        // Determine the longest key prefix that can be used to retrieve all
        // of the relevant log files.
        $candidatePrefix = ltrim(strtr(self::PREFIX_TEMPLATE, $parts), '/');
        $logKeyPrefix = $candidatePrefix;
        $index = strpos($candidatePrefix, self::PREFIX_WILDCARD);

        if ($index !== false) {
            $logKeyPrefix = substr($candidatePrefix, 0, $index);
        }

        // Create an iterator that will emit all of the objects matching the
        // key prefix.
        $objectsIterator = $this->s3Client->getIterator('ListObjects', [
            'Bucket' => $this->s3BucketName,
            'Prefix' => $logKeyPrefix,
        ]);

        // Apply regex and/or date filters to the objects iterator to emit only
        // log files matching the options.
        $objectsIterator = $this->applyRegexFilter(
            $objectsIterator,
            $logKeyPrefix,
            $candidatePrefix
        );

        $objectsIterator = $this->applyDateFilter(
            $objectsIterator,
            $startDate,
            $endDate
        );

        return $objectsIterator;
    }
private function buildListObjectsIterator(array $options)
    {
        // Extract and normalize the date values from the options
        $startDate = isset($options[self::START_DATE])
            ? $this->normalizeDateValue($options[self::START_DATE])
            : null;
        $endDate = isset($options[self::END_DATE])
            ? $this->normalizeDateValue($options[self::END_DATE])
            : null;

        // Determine the parts of the key prefix of the log files being read
        $parts = [
            'prefix' => isset($options[self::KEY_PREFIX])
                    ? $options[self::KEY_PREFIX]
                    : null,
            'account' => isset($options[self::ACCOUNT_ID])
                    ? $options[self::ACCOUNT_ID]
                    : self::PREFIX_WILDCARD,
            'region' => isset($options[self::LOG_REGION])
                    ? $options[self::LOG_REGION]
                    : self::PREFIX_WILDCARD,
            'date' => $this->determineDateForPrefix($startDate, $endDate),
        ];

        // Determine the longest key prefix that can be used to retrieve all
        // of the relevant log files.
        $candidatePrefix = ltrim(strtr(self::PREFIX_TEMPLATE, $parts), '/');
        $logKeyPrefix = $candidatePrefix;
        $index = strpos($candidatePrefix, self::PREFIX_WILDCARD);

        if ($index !== false) {
            $logKeyPrefix = substr($candidatePrefix, 0, $index);
        }

        // Create an iterator that will emit all of the objects matching the
        // key prefix.
        $objectsIterator = $this->s3Client->getIterator('ListObjects', [
            'Bucket' => $this->s3BucketName,
            'Prefix' => $logKeyPrefix,
        ]);

        // Apply regex and/or date filters to the objects iterator to emit only
        // log files matching the options.
        $objectsIterator = $this->applyRegexFilter(
            $objectsIterator,
            $logKeyPrefix,
            $candidatePrefix
        );

        $objectsIterator = $this->applyDateFilter(
            $objectsIterator,
            $startDate,
            $endDate
        );

        return $objectsIterator;
    }
private function buildListObjectsIterator ( array $ options ) { // Extract and normalize the date values from the options $ startDate = isset ( $ options [ self :: START_DATE ] ) ? $ this -> normalizeDateValue ( $ options [ self :: START_DATE ] ) : null ; $ endDate = isset ( $ options [ self :: END_DATE ] ) ? $ this -> normalizeDateValue ( $ options [ self :: END_DATE ] ) : null ; // Determine the parts of the key prefix of the log files being read $ parts = [ 'prefix' => isset ( $ options [ self :: KEY_PREFIX ] ) ? $ options [ self :: KEY_PREFIX ] : null , 'account' => isset ( $ options [ self :: ACCOUNT_ID ] ) ? $ options [ self :: ACCOUNT_ID ] : self :: PREFIX_WILDCARD , 'region' => isset ( $ options [ self :: LOG_REGION ] ) ? $ options [ self :: LOG_REGION ] : self :: PREFIX_WILDCARD , 'date' => $ this -> determineDateForPrefix ( $ startDate , $ endDate ) , ] ; // Determine the longest key prefix that can be used to retrieve all // of the relevant log files. $ candidatePrefix = ltrim ( strtr ( self :: PREFIX_TEMPLATE , $ parts ) , '/' ) ; $ logKeyPrefix = $ candidatePrefix ; $ index = strpos ( $ candidatePrefix , self :: PREFIX_WILDCARD ) ; if ( $ index !== false ) { $ logKeyPrefix = substr ( $ candidatePrefix , 0 , $ index ) ; } // Create an iterator that will emit all of the objects matching the // key prefix. $ objectsIterator = $ this -> s3Client -> getIterator ( 'ListObjects' , [ 'Bucket' => $ this -> s3BucketName , 'Prefix' => $ logKeyPrefix , ] ) ; // Apply regex and/or date filters to the objects iterator to emit only // log files matching the options. $ objectsIterator = $ this -> applyRegexFilter ( $ objectsIterator , $ logKeyPrefix , $ candidatePrefix ) ; $ objectsIterator = $ this -> applyDateFilter ( $ objectsIterator , $ startDate , $ endDate ) ; return $ objectsIterator ; }
Constructs an S3 ListObjects iterator, optionally decorated with
FilterIterators, based on the provided options.

@param array $options

@return \Iterator
Constructs an S3 ListObjects iterator optionally decorated with FilterIterators based on the provided options .