Completed
Push — master ( 993160...fd6048 )
by Peter
05:58
created

helpers.php ➔ secure_theme_asset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 1
cp 0
crap 2
rs 10
1
<?php
2
3
namespace PeterColes\Themes;
4
5
if (!function_exists('themes_path')) {
6
    /**
7
     * Get the path to the themes folder.
8
     *
9
     * @param  string  $path
10
     * @return string
11
     */
12
    function themes_path($path = '')
13
    {
14 27
        return app()->basePath().DIRECTORY_SEPARATOR.'themes'.($path ? DIRECTORY_SEPARATOR.$path : $path);
15
    }
16
}
17
18
if (!function_exists('theme_asset')) {
19
    /**
20
     * Generate an asset path for the application.
21
     *
22
     * @param  string  $path
23
     * @return string
24
     */
25
    function theme_asset($path, $secure = null)
26
    {
27 4
        $theme = app('themes')->getTheme();
28
29 4
        if ($theme && file_exists(public_path("$theme/$path"))) {
30 2
            return app('url')->asset("$theme/$path", $secure);
31
        }
32
33 2
        return app('url')->asset($path, $secure);
34
    }
35
}
36
37
if (!function_exists('secure_theme_asset')) {
38
    /**
39
     * Generate a secure asset path for the theme asset.
40
     *
41
     * @param  string  $path
42
     * @return string
43
     */
44
    function secure_theme_asset($path)
45
    {
46
        return theme_asset($path, true);
47
    }
48
}
49