/home/techb158/immovalet.com/vendor/aws/aws-sdk-php/src/CloudTrail
Edit: /home/techb158/immovalet.com/vendor/aws/aws-sdk-php/src/CloudTrail/LogRecordIterator.php (5074B)
$s3BucketName,
'Key' => $s3ObjectKey,
]]);
return new self($logFileReader, $logFileIterator);
}
/**
* @param LogFileReader $logFileReader
* @param \Iterator $logFileIterator
*/
public function __construct(
LogFileReader $logFileReader,
\Iterator $logFileIterator
) {
$this->logFileReader = $logFileReader;
$this->logFileIterator = $logFileIterator;
$this->records = array();
$this->recordIndex = 0;
}
/**
* Returns the current log record as an array.
*
* @return array|false
*/
public function current()
{
return $this->valid() ? $this->records[$this->recordIndex] : false;
}
public function next()
{
$this->recordIndex++;
// If all the records have been exhausted, get more records from the
// next log file.
while (!$this->valid()) {
$this->logFileIterator->next();
$success = $this->loadRecordsFromCurrentLogFile();
if (!$success) {
// The objects iterator is exhausted as well, so stop trying
break;
}
}
}
public function key()
{
if ($logFile = $this->logFileIterator->current()) {
return $logFile['Key'] . '.' . $this->recordIndex;
}
return null;
}
public function valid()
{
return isset($this->records[$this->recordIndex]);
}
public function rewind()
{
$this->logFileIterator->rewind();
$this->loadRecordsFromCurrentLogFile();
}
public function getInnerIterator()
{
return $this->logFileIterator;
}
/**
* Examines the current file in the `logFileIterator` and attempts to read
* it and load log records from it using the `logFileReader`. This method
* expects that items pulled from the iterator will take the form:
*
* [
* 'Bucket' => '...',
* 'Key' => '...',
* ]
*
* @return bool Returns `true` if records were loaded and `false` if no
* records were found
*/
private function loadRecordsFromCurrentLogFile()
{
$this->recordIndex = 0;
$this->records = array();
$logFile = $this->logFileIterator->current();
if ($logFile && isset($logFile['Bucket']) && isset($logFile['Key'])) {
$this->records = $this->logFileReader->read(
$logFile['Bucket'],
$logFile['Key']
);
}
return (bool) $logFile;
}
}