Lines 83.33% 5 / 6
Methods 66.66% 2 / 3
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 fromSection 100.00% 4 / 4 100.00% 1 / 1 1
 requireToken 0.00% 0 / 1 0.00% 0 / 1 2
11final readonly class HttpAdminConfig
12{
13    public function __construct(
14        public ?HttpListenAddress $listen,
15        #[SensitiveParameter]
16        public ?string $token,
17    ) {}
18
19    /** @throws ConfigurationException */
20    public static function fromSection(#[SensitiveParameter] ConfigSection $admin): self
21    {
22        return new self(
23            listen: $admin->findSwitchableValue('listen', HttpListenAddress::parse(...)),
24            token: $admin->findSwitchableValue('token', strval(...)),
25        );
26    }
27
28    /** @throws ConfigurationException */
29    public function requireToken(): string
30    {
31        return $this->token ?? throw ConfigurationException::createForReason(ConfigurationError::AdminTokenMissing);
32    }
33}