ServerBag   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
dl 0
loc 35
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A __construct() 0 8 3
1
<?php
2
3
namespace App\Support\Console;
4
5
class ServerBag
6
{
7
    /**
8
     * Hold the values.
9
     *
10
     * @var array
11
     */
12
    protected $server;
13
14
    /**
15
     * ServerBag constructor. Allow us to override some values for testing.
16
     *
17
     * @param array|null $overrides
18
     */
19 210
    public function __construct(array $overrides = null)
20
    {
21 210
        $overrides = $overrides ? array_change_key_case($overrides, CASE_LOWER) : [];
22
23 210
        foreach ($_SERVER as $key => $value) {
24 210
            $key = strtolower($key);
25
26 210
            $this->server[$key] = $overrides[$key] ?? $value;
27
        }
28
    }
29
30
    /**
31
     * Get a server variable.
32
     *
33
     * @param $key
34
     *
35
     * @return mixed
36
     */
37 3
    public function get($key)
38
    {
39 3
        return $this->server[strtolower($key)];
40
    }
41
}
42