Completed
Push — master ( 741414...60a4d7 )
by Jeroen
02:08
created

helpers.php ➔ on_page()   A

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
     * @return bool
10
     */
11
    function on_page($path)
12
    {
13
        return request()->is($path);
14
    }
15
}
16
17
if (!function_exists('on_route')) {
18
    /**
19
     * Determine if the visitor is on the given page.
20
     * This uses the named route.
21
     *
22
     * @param string $route
23
     * @return bool
24
     */
25
    function on_route($route)
26
    {
27
        return request()->routeIs($route);
28
    }
29
}
30
31
if (!function_exists('return_if')) {
32
    /**
33
     * Return the value if the condition is true.
34
     *
35
     * @param mixed $condition
36
     * @param mixed $value
37
     * @return void
38
     */
39
    function return_if($condition, $value)
40
    {
41
        if ($condition) {
42
            return $value;
43
        }
44
    }
45
}
46