helpers.php ➔ config()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 2
dl 0
loc 12
ccs 5
cts 5
cp 1
crap 3
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Container\Container;
4
use Illuminate\Support\Collection;
5
6
7
if (! function_exists('app')) {
8
    /**
9
     * Get the available container instance.
10
     *
11
     * @param  string  $make
12
     * @param  array   $parameters
13
     * @return mixed|Container
14
     */
15
    function app($make = null, $parameters = [])
16
    {
17 4
        if (is_null($make)) {
18 4
            return Container::getInstance();
19
        }
20
21 3
        return Container::getInstance()->make($make, $parameters);
22
    }
23
}
24
25
26
if (! function_exists('config')) {
27
    /**
28
     * Get / set the specified configuration value.
29
     *
30
     * If an array is passed as the key, we will assume you want to set an array of values.
31
     *
32
     * @param  array|string  $key
33
     * @param  mixed  $default
34
     * @return mixed
35
     */
36
    function config($key = null, $default = null)
37
    {
38 3
        if (is_null($key)) {
39 1
            return app('config');
40
        }
41
42 2
        if (is_array($key)) {
43 1
            return app('config')->set($key);
44
        }
45
46 2
        return app('config')->get($key, $default);
47
    }
48
}
49
50
if (! function_exists('collect')) {
51
    /**
52
     * Create a collection from the given value.
53
     *
54
     * @param  mixed  $value
55
     * @return \Illuminate\Support\Collection
56
     */
57
    function collect($value = null)
58
    {
59
        return new Collection($value);
60
    }
61
}