Completed
Push — master ( b8c901...502914 )
by ARCANEDEV
9s
created

helpers.php ➔ request()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 10
rs 9.4285
1
<?php
2
3
if ( ! function_exists('laravel_version')) {
4
    /**
5
     * Get laravel version or check if the same version
6
     *
7
     * @param  string|null $version
8
     *
9
     * @return string
10
     */
11
    function laravel_version($version = null) {
12
        $app = app();
13
        $appVersion = $app::VERSION;
14
        if (is_null($version)) {
15
            return $appVersion;
16
        }
17
        return substr($appVersion, 0, strlen($version)) === $version;
18
    }
19
}
20
21
if ( ! function_exists('request')) {
22
    /**
23
     * Get an instance of the current request or an input item from the request.
24
     *
25
     * @param  string  $key
26
     * @param  mixed   $default
27
     *
28
     * @return \Illuminate\Http\Request|string|array
29
     */
30
    function request($key = null, $default = null)
31
    {
32
        /** @var Illuminate\Http\Request $request */
33
        $request = app('request');
34
        if (is_null($key)) {
35
            return $request;
36
        }
37
38
        return $request->input($key, $default);
39
    }
40
}
41
42
if ( ! function_exists('route_is')) {
43
    /**
44
     * Check if route(s) is the current route.
45
     *
46
     * @param  array|string  $routes
47
     *
48
     * @return bool
49
     */
50
    function route_is($routes)
51
    {
52
        if ( ! is_array($routes)) {
53
            $routes = [$routes];
54
        }
55
56
        /** @var Illuminate\Routing\Router $router */
57
        $router = app('router');
58
59
        return call_user_func_array([$router, 'is'], $routes);
60
    }
61
}
62
63
if ( ! function_exists('str_studly')) {
64
    /**
65
     * Convert a value to studly caps case.
66
     *
67
     * @param  string  $value
68
     *
69
     * @return string
70
     */
71
    function str_studly($value)
72
    {
73
        return Illuminate\Support\Str::studly($value);
74
    }
75
}
76