Completed
Push — master ( 6130d0...57338d )
by Dev
24:32 queued 11:23
created

PageCanonicalService::isForDefaultLocale()   A

Complexity

Conditions 6
Paths 10

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 6
eloc 6
c 2
b 0
f 0
nc 10
nop 1
dl 0
loc 8
ccs 0
cts 8
cp 0
crap 42
rs 9.2222
1
<?php
2
3
namespace PiedWeb\CMSBundle\Service;
4
5
use Symfony\Component\HttpFoundation\RequestStack;
6
use Symfony\Component\Routing\Router;
7
8
class PageCanonicalService
9
{
10
    protected $request;
11
    protected $router;
12
    protected $defaultLocaleWithoutPrefix;
13
    protected $defaultLocale;
14
    protected $locale;
15
    protected $params;
16
17
    public function __construct(
18
        RequestStack $request,
19
        Router $router,
20
        bool $defaultLocaleWithoutPrefix = false,
21
        ?string $defaultLocale = null
22
    ) {
23
        $this->request = $request;
24
        $this->router = $router;
25
        $this->defaultLocaleWithoutPrefix = $defaultLocaleWithoutPrefix;
26
        $this->defaultLocale = $defaultLocale;
27
    }
28
29
    public function generatePathForHomepage(?string $expectedLocale = null)
0 ignored issues
show
Unused Code introduced by
The parameter $expectedLocale is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

29
    public function generatePathForHomepage(/** @scrutinizer ignore-unused */ ?string $expectedLocale = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
    {
31
        return $this->router->generate('piedweb_cms_homepage');
32
    }
33
34
    /**
35
     * @var string Permit to generate a link for another language than the current request
36
     */
37
    public function generatePathForPage(string $slug, ?string $expectedLocale = null)
38
    {
39
        if ('' == $slug) {
40
            return $this->generatePathForHomepage($expectedLocale);
41
        }
42
43
        return $this->router->generate('piedweb_cms_page', ['slug' => $slug]);
44
    }
45
}
46