helpers.php ➔ on_route()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
if (!function_exists('on_page')) {
4
    /**
5
     * Determine if the visitor is on the given page.
6
     * This uses the URL path.
7
     *
8
     * @param string $path
9
     *
10
     * @return bool
11
     */
12
    function on_page($path)
13
    {
14
        return request()->is($path);
15
    }
16
}
17
18
if (!function_exists('on_route')) {
19
    /**
20
     * Determine if the visitor is on the given page.
21
     * This uses the named route.
22
     *
23
     * @param string $route
24
     *
25
     * @return bool
26
     */
27
    function on_route($route)
28
    {
29
        return request()->routeIs($route);
30
    }
31
}
32
33
if (!function_exists('return_if')) {
34
    /**
35
     * Return the value if the condition is true.
36
     *
37
     * @param mixed $condition
38
     * @param mixed $value
39
     *
40
     * @return void
41
     */
42
    function return_if($condition, $value)
43
    {
44
        if ($condition) {
45
            return $value;
46
        }
47
    }
48
}
49