Test Failed
Push — stable ( cb1f97...b2434c )
by Nuno
01:59
created

helpers.php ➔ app_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 LaravelZero\Framework\Container;
4
5
if (! function_exists('app')) {
6
    /**
7
     * Get the available container instance.
8
     *
9
     * @param  string $abstract
10
     * @param  array $parameters
11
     *
12
     * @return mixed|\LaravelZero\Framework\Container
13
     */
14
    function app($abstract = null, array $parameters = [])
15
    {
16
        if (is_null($abstract)) {
17
            return Container::getInstance();
18
        }
19
20
        return Container::getInstance()
21
            ->make($abstract, $parameters);
22
    }
23
}
24
25
if (! function_exists('app_path')) {
26
    /**
27
     * Get the path to the application folder.
28
     *
29
     * @param  string  $path
30
     * @return string
31
     */
32
    function app_path($path = '')
33
    {
34
        return app('path').($path ? DIRECTORY_SEPARATOR.$path : $path);
35
    }
36
}
37
38
if (! function_exists('config')) {
39
    /**
40
     * Get / set the specified configuration value.
41
     *
42
     * If an array is passed as the key, we will assume you want to set an array of values.
43
     *
44
     * @param  array|string $key
45
     * @param  mixed $default
46
     *
47
     * @return mixed|\Illuminate\Config\Repository
48
     */
49
    function config($key = null, $default = null)
50
    {
51
        if (is_null($key)) {
52
            return app('config');
53
        }
54
        if (is_array($key)) {
55
            return app('config')->set($key);
56
        }
57
58
        return app('config')->get($key, $default);
59
    }
60
}
61
62
if (! function_exists('event')) {
63
    /**
64
     * Dispatch an event and call the listeners.
65
     *
66
     * @param  mixed $event
0 ignored issues
show
Bug introduced by
There is no parameter named $event. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
67
     * @param  mixed $payload
0 ignored issues
show
Bug introduced by
There is no parameter named $payload. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
68
     * @param  bool $halt
0 ignored issues
show
Bug introduced by
There is no parameter named $halt. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
69
     *
70
     * @return array|null
71
     */
72
    function event(...$args)
73
    {
74
        return app('events')->dispatch(...$args);
75
    }
76
}
77
78
if (! function_exists('base_path')) {
79
    /**
80
     * Get the path to the base of the install.
81
     *
82
     * @param  string $path
83
     *
84
     * @return string
85
     */
86
    function base_path($path = '')
87
    {
88
        return app()->basePath($path);
89
    }
90
}
91
92
if (! function_exists('config_path')) {
93
    /**
94
     * Get the configuration path.
95
     *
96
     * @param  string $path
97
     *
98
     * @return string
99
     */
100
    function config_path($path = '')
101
    {
102
        return app()->configPath($path);
103
    }
104
}
105
106
if (! function_exists('database_path')) {
107
    /**
108
     * Get the database path.
109
     *
110
     * @param  string $path
111
     *
112
     * @return string
113
     */
114
    function database_path($path = '')
115
    {
116
        return app()->databasePath($path);
117
    }
118
}
119
120
if (! function_exists('resource_path')) {
121
    /**
122
     * Get the path to the resources folder.
123
     *
124
     * @param  string $path
125
     *
126
     * @return string
127
     */
128
    function resource_path($path = '')
129
    {
130
        return app()->resourcePath($path);
131
    }
132
}
133
134
if (! function_exists('storage_path')) {
135
    /**
136
     * Get the path to the storage folder.
137
     *
138
     * @param  string $path
139
     *
140
     * @return string
141
     */
142
    function storage_path($path = '')
143
    {
144
        return app()->storagePath().($path ? DIRECTORY_SEPARATOR.$path : $path);
145
    }
146
}
147