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;
    }