<?php

namespace App\Services\Certification;

final class CertificationResult
{
    public static function make(
        string $module,
        int $score,
        string $status,
        array $warnings = [],
        array $errors = [],
        array $meta = []
    ): array {
        return [
            'module' => $module,
            'score' => max(0, min(100, $score)),
            'status' => $status,
            'warnings' => $warnings,
            'errors' => $errors,
            'meta' => $meta
        ];
    }

    public static function pass(
        string $module,
        array $meta = []
    ): array {
        return self::make(
            $module,
            100,
            'PASS',
            [],
            [],
            $meta
        );
    }

    public static function warning(
        string $module,
        int $score,
        array $warnings,
        array $meta = []
    ): array {
        return self::make(
            $module,
            $score,
            'WARNING',
            $warnings,
            [],
            $meta
        );
    }

    public static function fail(
        string $module,
        array $errors,
        array $warnings = [],
        array $meta = []
    ): array {
        return self::make(
            $module,
            0,
            'FAIL',
            $warnings,
            $errors,
            $meta
        );
    }
}
