Test Failed
Pull Request — master (#85)
by Keoghan
06:33
created

ServerBag   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

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
    public function __construct(array $overrides = null)
20
    {
21
        $overrides = $overrides ? array_change_key_case($overrides, CASE_LOWER) : [];
22
23
        foreach ($_SERVER as $key => $value) {
24
            $key = strtolower($key);
25
26
            $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
    public function get($key)
38
    {
39
        return $this->server[strtolower($key)];
40
    }
41
}
42