Automattic\WooCommerce\Internal\Admin\Logging\FileV2
FileController::rotate_file
Get all the rotations of a file and increment them, so that they overwrite the previous file with that rotation.
Method of the class: FileController{}
No Hooks.
Returns
true|false. True if the file and all its rotations were successfully rotated.
Usage
// private - for code of main (parent) class only $result = $this->rotate_file( $file ): bool;
- $file(File) (required)
- The un-rotated ("current") iteration of the file to rotate.
FileController::rotate_file() FileController::rotate file code WC 11.0.1
private function rotate_file( File $file ): bool {
$rotations = $this->get_rotation_siblings( $file );
$max_rotation_marker = self::MAX_FILE_ROTATIONS - 1;
// Don't rotate a file with the maximum rotation.
unset( $rotations[ $max_rotation_marker ] );
$results = array();
// Rotate starting with oldest first and working backwards.
for ( $i = $max_rotation_marker; $i >= 0; $i -- ) {
if ( isset( $rotations[ $i ] ) ) {
$results[] = $rotations[ $i ]->rotate();
}
}
$results[] = $file->rotate();
return ! in_array( false, $results, true );
}