<?php

declare(strict_types=1);

namespace PpPhp\Core\Platform\Services\Blueprint;

use PpPhp\Core\Platform\Foundation\PlatformIdentity;
use PpPhp\Core\Platform\Foundation\PlatformMetadata;
use PpPhp\Core\Platform\Foundation\PlatformVersion;

final class BlueprintBuilder
{
    private string $id = '';
    private string $type = 'service-blueprint';
    private string $label = '';
    private string $version = '1.0.0';
    private string $status = 'compiled';
    private array $metadata = [];
    private array $dependencies = [];
    private array $capabilities = [];
    private string $lifecycle = 'singleton';
    private string $visibility = 'public';
    private array $runtimePolicy = [];
    private array $validation = [];

    public function id(string $id): self { $this->id = $id; return $this; }
    public function type(string $type): self { $this->type = $type; return $this; }
    public function label(string $label): self { $this->label = $label; return $this; }
    public function version(string $version): self { $this->version = $version; return $this; }
    public function status(string $status): self { $this->status = $status; return $this; }
    public function metadata(array $metadata): self { $this->metadata = $metadata; return $this; }
    public function dependencies(array $dependencies): self { $this->dependencies = $dependencies; return $this; }
    public function capabilities(array $capabilities): self { $this->capabilities = $capabilities; return $this; }
    public function lifecycle(string $lifecycle): self { $this->lifecycle = $lifecycle; return $this; }
    public function visibility(string $visibility): self { $this->visibility = $visibility; return $this; }
    public function runtimePolicy(array $runtimePolicy): self { $this->runtimePolicy = $runtimePolicy; return $this; }
    public function validation(array $validation): self { $this->validation = $validation; return $this; }

    public function build(): ServiceBlueprint
    {
        return new ServiceBlueprint(
            new PlatformIdentity($this->id, $this->type, $this->label),
            new PlatformVersion($this->version, $this->status),
            new PlatformMetadata($this->metadata),
            $this->dependencies,
            $this->capabilities,
            $this->lifecycle,
            $this->visibility,
            $this->runtimePolicy,
            $this->validation
        );
    }
}
