Lines 100.00% 8 / 8
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
AppOverride 100.00% 8 / 8 100.00% 2 / 2 2 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 fromSection 100.00% 7 / 7 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Config;
6
7use Stewart\Contracts\App\AppId;
8use Stewart\Contracts\Exception\IdentifierException;
9use Stewart\Runtime\Exception\ConfigurationException;
10
11final readonly class AppOverride
12{
13    /** @param array<string, mixed> $options */
14    public function __construct(
15        public AppId $id,
16        public bool $enabled,
17        public bool $paused,
18        public ?int $worker,
19        public array $options,
20    ) {}
21
22    /**
23     * @throws ConfigurationException
24     * @throws IdentifierException
25     */
26    public static function fromSection(ConfigSection $app, string $id): self
27    {
28        return new self(
29            id: new AppId($id),
30            enabled: $app->readBool('enabled'),
31            paused: $app->readBool('paused'),
32            worker: $app->findInt('worker'),
33            options: $app->readMap('options'),
34        );
35    }
36}