Passed
Push — master ( 07890b...2a1b1e )
by Afshin
02:34
created

config_path()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
function route(string $name ,array $params = [])
4
{
5
    $url = new \Core\Helpers\Url($GLOBALS['container']);
6
    return $url->get($name , $params);
7
}
8
9
function url(string $name ,array $params = [])
10
{
11
    $url = new \Core\Helpers\Url($GLOBALS['container']);
12
    return $url->get($name , $params);
13
}
14
15
// translate
16
function trans($key , $replace = []){
17
    $container = $GLOBALS['container'];
18
    return $container->translator->trans($key,$replace);
19
}
20
21
function public_path(string $uri = '') {
22
    $container = $GLOBALS['container'];
23
    $settings = $container->settings;
0 ignored issues
show
Unused Code introduced by
The assignment to $settings is dead and can be removed.
Loading history...
24
    $request = $container->request;
25
26
    $url = new \Core\Helpers\Url($container);
27
28
    $url_asset = $url->getBasePath($request) .'/'. $uri;
29
    return $url_asset;
30
}
31
32
if (!function_exists('base_path')) {
33
    /**
34
     * Get the path to the base folder
35
     *
36
     * @return string
37
     */
38
    function base_path()
39
    {
40
        return dirname(__DIR__);
41
    }
42
}
43
if (!function_exists('app_path')) {
44
    /**
45
     * Get the path to the application folder
46
     *
47
     * @return string
48
     */
49
    function app_path()
50
    {
51
        return base_path() . '/app';
52
    }
53
}
54
if (!function_exists('config_path')) {
55
    /**
56
     * Get the path to the config folder
57
     *
58
     * @return string
59
     */
60
    function config_path()
61
    {
62
        return base_path() . '/config';
63
    }
64
}
65
66
if (!function_exists('storage_path')) {
67
    /**
68
     * Get the path to the storage folder
69
     *
70
     * @return string
71
     */
72
    function storage_path()
73
    {
74
        return base_path() . '/storage';
75
    }
76
}
77
78
79
function asset(string $uri = '') {
80
    $url = public_path();
81
    $url_asset = $url.'assets/'.$uri;
82
    return $url_asset;
83
}
84
85
function get_gravatar( $email, $s = 380, $d = 'mm', $r = 'g', $img = false, $atts = array() ) {
86
    $url = 'https://www.gravatar.com/avatar/';
87
    $url .= md5( strtolower( trim( $email ) ) );
88
    $url .= "?s=$s&d=$d&r=$r";
89
    if ( $img ) {
90
        $url = '<img src="' . $url . '"';
91
        foreach ( $atts as $key => $val )
92
            $url .= ' ' . $key . '="' . $val . '"';
93
        $url .= ' />';
94
    }
95
    return $url;
96
}