helpers.php ➔ config()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 2
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
use Illuminate\Container\Container;
4
5
if (! function_exists('config')) {
6
    /**
7
     * Get / set the specified configuration value.
8
     *
9
     * If an array is passed as the key, we will assume you want to set an array of values.
10
     *
11
     * @param  array|string  $key
12
     * @param  mixed  $default
13
     * @return mixed
14
     */
15
    function config($key = null, $default = null)
16
    {
17
        if (is_null($key)) {
18
            return app('config');
19
        }
20
21
        if (is_array($key)) {
22
            return app('config')->set($key);
0 ignored issues
show
Bug introduced by
The method set() does not seem to exist on object<Illuminate\Container\Container>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
        }
24
25
        return app('config')->get($key, $default);
0 ignored issues
show
Unused Code introduced by
The call to Container::get() has too many arguments starting with $default.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
26
    }
27
}
28
29
if (! function_exists('app')) {
30
    /**
31
     * Get the available container instance.
32
     *
33
     * @param  string  $abstract
34
     * @param  array   $parameters
35
     * @return Illuminate\Container\Container
36
     */
37
    function app($abstract = null, array $parameters = [])
38
    {
39
        if (is_null($abstract)) {
40
            return Container::getInstance();
41
        }
42
43
        return empty($parameters)
44
            ? Container::getInstance()->make($abstract)
45
            : Container::getInstance()->makeWith($abstract, $parameters);
46
    }
47
}