helpers.php ➔ laravel_version()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
if ( ! function_exists('laravel_version')) {
6
    /**
7
     * Get laravel version or check if the same version
8
     *
9
     * @param  string|null $version
10
     *
11
     * @return string|bool
12
     */
13
    function laravel_version(string $version = null) {
14
        $appVersion = app()->version();
15
16
        if (is_null($version)) {
17
            return $appVersion;
18
        }
19
20
        return substr($appVersion, 0, strlen($version)) === $version;
21
    }
22
}
23
24
if ( ! function_exists('route_is')) {
25
    /**
26
     * Check if route(s) is the current route.
27
     *
28
     * @param  array|string  $routes
29
     *
30
     * @return bool
31
     */
32
    function route_is($routes): bool
33
    {
34
        if ( ! is_array($routes)) {
35
            $routes = [$routes];
36
        }
37
38
        /** @var Illuminate\Routing\Router $router */
39
        $router = app('router');
40
41
        return call_user_func_array([$router, 'is'], $routes);
42
    }
43
}
44