Passed
Push — master ( 9013bb...125cf1 )
by Kirill
03:56
created

HttpConfig   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBasePath() 0 3 1
A getBaseHeaders() 0 3 1
A getMiddleware() 0 3 1
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Http\Config;
13
14
use Spiral\Core\Container\Autowire;
15
use Spiral\Core\InjectableConfig;
16
17
final class HttpConfig extends InjectableConfig
18
{
19
    public const CONFIG = 'http';
20
21
    /**
22
     * @var array
23
     */
24
    protected $config = [
25
        'basePath'   => '/',
26
        'headers'    => [
27
            'Content-Type' => 'text/html; charset=UTF-8'
28
        ],
29
        'middleware' => [],
30
    ];
31
32
    /**
33
     * @return string
34
     */
35
    public function getBasePath(): string
36
    {
37
        return $this->config['basePath'];
38
    }
39
40
    /**
41
     * Initial set of headers.
42
     *
43
     * @return array
44
     */
45
    public function getBaseHeaders(): array
46
    {
47
        return $this->config['headers'];
48
    }
49
50
    /**
51
     * Initial middleware set.
52
     *
53
     * @return array|Autowire[]
54
     */
55
    public function getMiddleware(): array
56
    {
57
        return $this->config['middleware'] ?? $this->config['middlewares'];
58
    }
59
}
60