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
HttpConfig 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 Stewart\Runtime\Exception\ConfigurationException;
8
9final readonly class HttpConfig
10{
11    public function __construct(
12        public ?HttpListenAddress $listen,
13        public HttpAdminConfig $admin,
14    ) {}
15
16    /** @throws ConfigurationException */
17    public static function fromSection(ConfigSection $http): self
18    {
19        return new self(
20            listen: $http->findSwitchableValue('listen', HttpListenAddress::parse(...)),
21            admin: HttpAdminConfig::fromSection($http->readSection('admin')),
22        );
23    }
24}