<?php

declare(strict_types=1);

namespace PpPhp\Core\Diagnostics\Formatters;

use PpPhp\Core\Diagnostics\Contracts\DiagnosticFormatterInterface;
use PpPhp\Core\Diagnostics\Results\DiagnosticReport;

final class JsonDiagnosticFormatter implements DiagnosticFormatterInterface
{
    public function format(DiagnosticReport $report): string
    {
        return json_encode($report->toArray(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) ?: '{}';
    }
}
