static function cleanBuffers(?int $targetLevel = null, bool $catchExceptions = false): bool
    {
        $level = 0;
        $stopLevel = $targetLevel ?? 0;

        foreach (self::iterateBufferLevels(PHP_OUTPUT_HANDLER_CLEANABLE) as $level) {
            if ($level <= $stopLevel) {
                break;
            }

            try {
                ob_end_clean();
            } catch (\Throwable $e) {
                if (!$catchExceptions) {
                    throw $e;
                }
            }
        }

        return $targetLevel === null || $level <= $targetLevel;
    }