Passed
Push — master ( 58955b...e00fc3 )
by Ben
05:11
created

helpers.php ➔ localeConfig()   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 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Thinktomorrow\Locale\LocaleUrl;
4
5 1
if (!function_exists('localeurl')) {
6
    /**
7
     * @param $url
8
     * @param null  $locale
9
     * @param array $extra
10
     * @param null  $secure
11
     *
12
     * @return mixed
13
     */
14
    function localeurl($url, $locale = null, $extra = [], $secure = null)
15
    {
16 3
        return app(LocaleUrl::class)->to($url, $locale, $extra, $secure);
17
    }
18
}
19
20 1
if (!function_exists('localeroute')) {
21
    /**
22
     * @param $name
23
     * @param null  $locale
24
     * @param array $parameters
25
     * @param bool  $asCanonical
26
     *
27
     * @return
28
     */
29
    function localeroute($name, $locale = null, $parameters = [], $asCanonical = true)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
30
    {
31 5
        return app(LocaleUrl::class)->route($name, $locale, $parameters, $asCanonical);
32
    }
33
}
34
35
/*
36
 * Detect locale and return the active segment. Useful for route segment injections
37
 */
38 1
if (!function_exists('localeRoutePrefix')) {
39
    function localeRoutePrefix()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
40
    {
41 1
        return app(\Thinktomorrow\Locale\Detect::class)
42 1
                    ->detectLocale()
43 1
                    ->getScope()
44 1
                    ->activeSegment();
45
    }
46
}
47
48
/*
49
 * Get the sanitized locale config which gives you access to the canonicals
50
 */
51 1
if (!function_exists('localeConfig')) {
52
    function localeConfig()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
53
    {
54
        return app(\Thinktomorrow\Locale\Detect::class)->getConfig();
55
    }
56
}
57