Test Failed
Branch feature__set_up_scrutinizer (ea6624)
by Robin
06:04 queued 02:46
created

ServerBag   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 34
ccs 8
cts 8
cp 1
rs 10
c 0
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
6
class ServerBag
7
{
8
    /**
9
     * Hold the values
10
     *
11
     * @var array
12
     */
13
    protected $server;
14
15
    /**
16
     * ServerBag constructor. Allow us to override some values for testing.
17
     *
18
     * @param array|null $overrides
19
     */
20 50
    public function __construct(array $overrides = null)
21
    {
22 50
        $overrides = $overrides ? array_change_key_case($overrides, CASE_LOWER) : [];
23
24 50
        foreach ($_SERVER as $key => $value) {
25 50
            $key = strtolower($key);
26
27 50
            $this->server[$key] = $overrides[$key] ?? $value;
28
        }
29 50
    }
30
31
    /**
32
     * Get a server variable
33
     *
34
     * @param $key
35
     * @return mixed
36
     */
37 50
    public function get($key)
38
    {
39 50
        return $this->server[strtolower($key)];
40
    }
41
}
42