Test Failed
Push — stable ( 81fca5...535a20 )
by Nuno
05:36
created

helpers.php ➔ config()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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