<?php

declare(strict_types=1);

namespace PpPhp\Core\Platform\Services\Blueprint;

final class BlueprintValidator
{
    /** @return string[] */
    public function validate(ServiceBlueprint $blueprint): array
    {
        $errors = [];

        if ($blueprint->id() === '') {
            $errors[] = 'Blueprint id is required.';
        }

        if ($blueprint->label() === '') {
            $errors[] = 'Blueprint label is required.';
        }

        if (!in_array($blueprint->lifecycle(), ['singleton', 'transient'], true)) {
            $errors[] = 'Blueprint lifecycle must be singleton or transient.';
        }

        if (!in_array($blueprint->visibility(), ['public', 'internal', 'private'], true)) {
            $errors[] = 'Blueprint visibility must be public, internal or private.';
        }

        return $errors;
    }
}
