Lines 100.00% 5 / 5
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
HttpAdminConfig 100.00% 5 / 5 100.00% 2 / 2 2 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 fromSection 100.00% 4 / 4 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Config;
6
7use SensitiveParameter;
8use Stewart\Runtime\Exception\ConfigurationException;
9
10final readonly class HttpAdminConfig
11{
12    public function __construct(
13        public ?HttpListenAddress $listen,
14        #[SensitiveParameter]
15        public ?string $token,
16    ) {}
17
18    /** @throws ConfigurationException */
19    public static function fromSection(#[SensitiveParameter] ConfigSection $admin): self
20    {
21        return new self(
22            listen: $admin->findSwitchableValue('listen', HttpListenAddress::parse(...)),
23            token: $admin->findSwitchableValue('token', strval(...)),
24        );
25    }
26}