Test Failed
Pull Request — stable (#25)
by Nuno
01:50
created

helpers.php ➔ base_path()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
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
61
if (! function_exists('base_path')) {
62
    /**
63
     * Get the path to the base of the install.
64
     *
65
     * @param  string  $path
66
     * @return string
67
     */
68
    function base_path($path = '')
69
    {
70
        return app()->basePath().($path ? DIRECTORY_SEPARATOR.$path : $path);
71
    }
72
}
73