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

helpers.php ➔ theme_asset()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 3
Bugs 0 Features 1
Metric Value
cc 3
eloc 5
c 3
b 0
f 1
nc 2
nop 2
dl 0
loc 10
ccs 4
cts 4
cp 1
crap 3
rs 9.4285
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