helpers.php ➔ csrf_token()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Codexshaper\WP\Application;
4
use Illuminate\Container\Container;
5
6
if (!function_exists('csrf_token')) {
7
    function csrf_token($action = 'wbp_nonce')
8
    {
9
        return wp_create_nonce($action);
10
    }
11
}
12
13
if (!function_exists('app')) {
14
    /**
15
     * Get the available container instance.
16
     *
17
     * @param string|null $abstract
18
     * @param array       $parameters
19
     *
20
     * @return mixed|\Illuminate\Contracts\Foundation\Application
21
     */
22
    function app($abstract = null, array $parameters = [])
0 ignored issues
show
Unused Code introduced by
The parameter $abstract is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $parameters is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24
        $app = new Application();
25
        var_dump($app->app);
0 ignored issues
show
Bug introduced by
The property app cannot be accessed from this context as it is declared protected in class CodexShaper\WP\Application.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
Security Debugging Code introduced by
var_dump($app->app); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
26
        die();
27
        if (is_null($abstract) && $container != null) {
0 ignored issues
show
Unused Code introduced by
if (is_null($abstract) &... return $container; } does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
28
            return $container;
29
        }
30
31
        return Container::getInstance()->make($abstract, $parameters);
32
    }
33
}
34
35
if (!function_exists('config')) {
36
    /**
37
     * Get / set the specified configuration value.
38
     *
39
     * If an array is passed as the key, we will assume you want to set an array of values.
40
     *
41
     * @param array|string|null $key
42
     * @param mixed             $default
43
     *
44
     * @return mixed|\Illuminate\Config\Repository
45
     */
46
    function config($key = null, $default = null)
47
    {
48
        if (is_null($key)) {
49
            return app('config');
50
        }
51
52
        if (is_array($key)) {
53
            return app('config')->set($key);
54
        }
55
56
        return app('config')->get($key, $default);
57
    }
58
}
59
60
if (!function_exists('view')) {
61
    function view($view, $data = [], $mergeData = [])
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $mergeData is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
62
    {
63
        global $app;
64
65
        if (!class_exists(\CodexShaper\Blade\View::class)) {
66
            throw new \Exception('View not resolved. Please install View');
67
        }
68
69
        return (new \CodexShaper\Blade\View([], '', $app))->make($view, $data = [], $mergeData = []);
70
    }
71
}
72