Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
BuildConfigDto
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 fromArray
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Core\Packaging\Dto;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11/**
12 * Data Transfer Object for Package Build Configuration.
13 *
14 * @package App\Core\Packaging\Dto
15 */
16final readonly class BuildConfigDto
17{
18    /**
19     * BuildConfigDto constructor.
20     *
21     * @param string $version Target package semantic version (e.g. 0.0.1).
22     * @param string $outputDir Absolute path to the output build directory.
23     * @param string $type Package type: 'full' or 'update'.
24     * @param string|null $fromVersion Base version for delta update package.
25     */
26    public function __construct(
27        public string $version,
28        public string $outputDir,
29        public string $type = 'full',
30        public ?string $fromVersion = null
31    ) {
32    }
33
34    /**
35     * Creates DTO from associative array.
36     *
37     * @param array<string, mixed> $data Configuration payload.
38     */
39    public static function fromArray(array $data): self
40    {
41        return new self(
42            version: (string) ($data['version'] ?? '0.0.1'),
43            outputDir: (string) ($data['outputDir'] ?? 'build'),
44            type: (string) ($data['type'] ?? 'full'),
45            fromVersion: isset($data['fromVersion']) ? (string) $data['fromVersion'] : null
46        );
47    }
48}