RequestDataSource::getLocaleFormParams()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Victoire\Bundle\CriteriaBundle\DataSource;
4
5
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
6
use Symfony\Component\HttpFoundation\RequestStack;
7
8
class RequestDataSource
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
9
{
10
    /**
11
     * @var RequestStack
12
     */
13
    private $requestStack;
14
    private $availableLocales;
15
16
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$availableLocales" missing
Loading history...
17
     * RequestCriteria constructor.
18
     *
19
     * @param RequestStack $requestStack
0 ignored issues
show
introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
20
     * @param              $availableLocales
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
21
     */
22
    public function __construct(RequestStack $requestStack, $availableLocales)
23
    {
24
        $this->requestStack = $requestStack;
25
        $this->availableLocales = $availableLocales;
26
    }
27
28
    public function getLocale()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
29
    {
30
        return $this->requestStack->getCurrentRequest()->getLocale();
31
    }
32
33
    public function getScheme()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
34
    {
35
        return $this->requestStack->getCurrentRequest()->getScheme();
36
    }
37
38 View Code Duplication
    public function getLocaleFormParams()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
introduced by
Missing function doc comment
Loading history...
39
    {
40
        return [
41
            'type'    => ChoiceType::class,
42
            'options' => [
43
                'choices'           => $this->availableLocales,
44
                'choices_as_values' => true,
45
                'choice_label'      => function ($value) {
46
                    return $value;
47
                },
48
            ],
49
        ];
50
    }
51
52
    public function getSchemeFormParams()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
53
    {
54
        return [
55
            'type'    => ChoiceType::class,
56
            'options' => [
57
                'choices' => [
58
                    'http'  => 'http',
59
                    'https' => 'https',
60
                ],
61
            ],
62
        ];
63
    }
64
}
65