Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
Profile
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
4 / 4
4
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
 hasDiConfig
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasParamsConfig
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 hasViews
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
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\Profile\Domain\Model;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11/**
12 * Profile Value Object.
13 *
14 * Represents an isolated application deployment profile with dedicated SQL, DI config, and view overrides.
15 *
16 * @package App\Core\Profile\Domain\Model
17 */
18final readonly class Profile
19{
20    /**
21     * Profile constructor.
22     *
23     * @param string $name       Profile machine name (e.g. 'admin', 'client').
24     * @param string $label      Human-readable profile title.
25     * @param string $basePath   Root filesystem directory for the profile.
26     * @param string $sqlPath    Directory containing profile SQL migrations and seeders.
27     * @param string $configPath Directory containing profile DI configuration.
28     * @param string $viewsPath  Directory containing profile Twig template overrides.
29     * @param string $srcPath    Directory containing profile PHP classes.
30     */
31    public function __construct(
32        public string $name,
33        public string $label,
34        public string $basePath,
35        public string $sqlPath,
36        public string $configPath,
37        public string $viewsPath,
38        public string $srcPath
39    ) {
40    }
41
42    /**
43     * Checks if the profile has custom DI configuration.
44     *
45     * @return bool True if di.php exists.
46     */
47    public function hasDiConfig(): bool
48    {
49        return file_exists($this->configPath . '/di.php');
50    }
51
52    /**
53     * Checks if the profile has custom parameters configuration.
54     *
55     * @return bool True if params.php exists.
56     */
57    public function hasParamsConfig(): bool
58    {
59        return file_exists($this->configPath . '/params.php');
60    }
61
62    /**
63     * Checks if the profile has custom Twig views.
64     *
65     * @return bool True if views directory exists.
66     */
67    public function hasViews(): bool
68    {
69        return is_dir($this->viewsPath);
70    }
71}