Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
SystemRequirement
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
2 / 2
2
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%
13 / 13
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\Modules\About\Domain\Model;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11/**
12 * System Requirement Benchmark Model.
13 *
14 * Represents an infrastructure, runtime, environment or security benchmark.
15 *
16 * @package App\Modules\About\Domain\Model
17 */
18final readonly class SystemRequirement
19{
20    /**
21     * SystemRequirement constructor.
22     *
23     * @param int    $id               Primary key ID.
24     * @param string $category         Category group (e.g. server, php, sql, cache, filesystem, security).
25     * @param string $requirementKey   Unique requirement identifier key.
26     * @param string $label            Human-readable label.
27     * @param string $recommendedValue Recommended target configuration value.
28     * @param string $minimumValue     Minimum acceptable value threshold.
29     * @param string $severity         Severity level (critical, warning, recommended).
30     * @param string $description      Detailed description of the requirement purpose.
31     * @param string $impactOnFailure  Specification of problems and risks if unfulfilled.
32     * @param int    $sortOrder        Display sort order within category.
33     * @param bool   $isActive         Whether the check is currently active.
34     */
35    public function __construct(
36        public int    $id,
37        public string $category,
38        public string $requirementKey,
39        public string $label,
40        public string $recommendedValue,
41        public string $minimumValue,
42        public string $severity,
43        public string $description,
44        public string $impactOnFailure,
45        public int    $sortOrder = 10,
46        public bool   $isActive = true
47    ) {
48    }
49
50    /**
51     * Creates instance from raw database array.
52     *
53     * @param array<string, mixed> $row Raw database row.
54     * @return self New instance.
55     */
56    public static function fromArray(array $row): self
57    {
58        return new self(
59            id: (int)($row['id'] ?? 0),
60            category: (string)($row['category'] ?? 'server'),
61            requirementKey: (string)($row['requirement_key'] ?? ''),
62            label: (string)($row['label'] ?? ''),
63            recommendedValue: (string)($row['recommended_value'] ?? ''),
64            minimumValue: (string)($row['minimum_value'] ?? ''),
65            severity: (string)($row['severity'] ?? 'recommended'),
66            description: (string)($row['description'] ?? ''),
67            impactOnFailure: (string)($row['impact_on_failure'] ?? ''),
68            sortOrder: (int)($row['sort_order'] ?? 10),
69            isActive: (bool)($row['is_active'] ?? true)
70        );
71    }
72}