protected function _rotateFile($filename)
    {
        $filePath = $this->_path . $filename;
        clearstatcache(true, $filePath);

        if (!file_exists($filePath) ||
            filesize($filePath) < $this->_size
        ) {
            return null;
        }

        $rotate = $this->_config['rotate'];
        if ($rotate === 0) {
            $result = unlink($filePath);
        } else {
            $result = rename($filePath, $filePath . '.' . time());
        }

        $files = glob($filePath . '.*');
        if ($files) {
            $filesToDelete = count($files) - $rotate;
            while ($filesToDelete > 0) {
                unlink(array_shift($files));
                $filesToDelete--;
            }
        }

        return $result;
    }
protected function _rotateFile($filename)
    {
        $filePath = $this->_path . $filename;
        clearstatcache(true, $filePath);

        if (!file_exists($filePath) ||
            filesize($filePath) < $this->_size
        ) {
            return null;
        }

        $rotate = $this->_config['rotate'];
        if ($rotate === 0) {
            $result = unlink($filePath);
        } else {
            $result = rename($filePath, $filePath . '.' . time());
        }

        $files = glob($filePath . '.*');
        if ($files) {
            $filesToDelete = count($files) - $rotate;
            while ($filesToDelete > 0) {
                unlink(array_shift($files));
                $filesToDelete--;
            }
        }

        return $result;
    }
protected function _rotateFile ( $ filename ) { $ filePath = $ this -> _path . $ filename ; clearstatcache ( true , $ filePath ) ; if ( ! file_exists ( $ filePath ) || filesize ( $ filePath ) < $ this -> _size ) { return null ; } $ rotate = $ this -> _config [ 'rotate' ] ; if ( $ rotate === 0 ) { $ result = unlink ( $ filePath ) ; } else { $ result = rename ( $ filePath , $ filePath . '.' . time ( ) ) ; } $ files = glob ( $ filePath . '.*' ) ; if ( $ files ) { $ filesToDelete = count ( $ files ) - $ rotate ; while ( $ filesToDelete > 0 ) { unlink ( array_shift ( $ files ) ) ; $ filesToDelete -- ; } } return $ result ; }
Rotate log file if size specified in config is reached.
Also if `rotate` count is reached oldest file is removed.

@param string $filename Log file name
@return bool|null True if rotated successfully or false in case of error.
Null if file doesn't need to be rotated.
Rotate log file if size specified in config is reached . Also if rotate count is reached oldest file is removed .