Completed
Branch feature/router-decorator (f7629b)
by Frédéric
02:12
created

Url::rawRouteUrl()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 3
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace CaribouFute\LocaleRoute\Prefix;
4
5
use CaribouFute\LocaleRoute\Prefix\Base;
6
use Illuminate\Translation\Translator;
7
8
class Url extends Base
9
{
10
    protected $separator = '/';
11
    protected $translator;
12
13 51
    public function __construct(Translator $translator)
14
    {
15 51
        $this->translator = $translator;
16 51
    }
17
18 14
    public function rawRouteUrl($locale, $route, array $urls = [])
19
    {
20 14
        $unlocaleUrl = isset($urls[$locale]) ? $urls[$locale] : $this->translator->get('routes.' . $route, [], $locale);
21 14
        return $unlocaleUrl;
22
    }
23
24 27
    public function addLocale($locale, $url)
25
    {
26 27
        return $this->getAddLocaleToUrl() ? parent::addLocale($locale, $url) : $url;
27
    }
28
}
29