<?php

/**
 * User-facing labels for Plugin Builder quality signals.
 *
 * @package LolaCore\PluginBuilder\Admin
 * @license GPL-2.0-or-later
 */

declare(strict_types=1);

namespace LolaCore\PluginBuilder\Admin;

use LolaCore\PluginBuilder\Generation\RuntimeValidator;

if (! defined('ABSPATH')) {
	exit;
}

/**
 * Formats load-test and code-review labels for admin and chat surfaces.
 */
final class ReviewQualityLabels {

	/**
	 * @param array{status?: string, message?: string, line?: int}|null $loadSafe
	 */
	public static function loadTestLabel( ?array $loadSafe ): string {
		$status = is_array($loadSafe) ? (string) ( $loadSafe['status'] ?? '' ) : '';

		return match ($status) {
			RuntimeValidator::STATUS_OK      => __('Passed', 'lolacore'),
			RuntimeValidator::STATUS_FATAL   => __('Failed', 'lolacore'),
			RuntimeValidator::STATUS_SKIPPED => __('Skipped', 'lolacore'),
			default                          => '',
		};
	}

	public static function codeReviewLabel( int $score ): string {
		if ($score <= 0) {
			return '';
		}

		return sprintf(
			/* translators: %d: automated code review score (0-100). */
			__('Code review: %d%%', 'lolacore'),
			$score
		);
	}
}
