<?php
declare(strict_types=1);

namespace PpPhp\Core\Designer\Build\Contracts;

final class ExportPackage
{
    public function __construct(
        private readonly string $applicationId,
        private readonly BuildManifest $manifest,
        private readonly string $exportPath,
        private readonly string $archiveName,
        private readonly array $writePlan = [],
        private readonly array $meta = []
    ) {}

    public static function create(string $applicationId, BuildManifest $manifest, string $exportPath, string $archiveName, array $writePlan = [], array $meta = []): self
    {
        return new self($applicationId, $manifest, $exportPath, $archiveName, $writePlan, $meta);
    }

    public function applicationId(): string { return $this->applicationId; }
    public function exportPath(): string { return $this->exportPath; }
    public function archiveName(): string { return $this->archiveName; }

    public function toArray(): array
    {
        return [
            'applicationId' => $this->applicationId,
            'exportPath' => $this->exportPath,
            'archiveName' => $this->archiveName,
            'manifest' => $this->manifest->toArray(),
            'artifacts' => count($this->manifest->artifacts()),
            'writePlan' => $this->writePlan,
            'meta' => $this->meta,
        ];
    }
}
