WordPress at Your Fingertips
function is not described

WC_Log_Handler_File::increment_log_infix() protected WC 1.0

Increment a log file suffix.

{} It's a method of the class: WC_Log_Handler_File{}

No Hooks.

Return

true|false. True if increment was successful, otherwise false.

Usage

// protected - for code of main (parent) or child class
$result = $this->increment_log_infix( $handle, $number );
$handle(string) (required)
Log handle.
$number(null|int)
Log suffix number to be incremented.
Default: null

Code of WC_Log_Handler_File::increment_log_infix() WC 5.8.0

protected function increment_log_infix( $handle, $number = null ) {
	if ( null === $number ) {
		$suffix      = '';
		$next_suffix = '.0';
	} else {
		$suffix      = '.' . $number;
		$next_suffix = '.' . ( $number + 1 );
	}

	$rename_from = self::get_log_file_path( "{$handle}{$suffix}" );
	$rename_to   = self::get_log_file_path( "{$handle}{$next_suffix}" );

	if ( $this->is_open( $rename_from ) ) {
		$this->close( $rename_from );
	}

	if ( is_writable( $rename_from ) ) { // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_is_writable
		return rename( $rename_from, $rename_to ); // phpcs:ignore WordPress.VIP.FileSystemWritesDisallow.file_ops_rename
	} else {
		return false;
	}

}