Completed
Push — master ( 64470f...3a69fd )
by Florian
02:24
created

Parameters::setLang()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Laposte\DatanovaBundle\Model;
4
5
use Symfony\Component\HttpFoundation\ParameterBag;
6
7
/**
8
 * @author Florian Ajir <[email protected]>
9
 */
10
abstract class Parameters extends ParameterBag
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 6
    public function __construct(array $parameters = array())
16
    {
17 6
        parent::__construct($parameters);
18 6
    }
19
20
    /**
21
     * @return array
22
     */
23 2
    public function getParameters()
24
    {
25 2
        return $this->parameters;
26
    }
27
28
    /**
29
     * @return string $query
30
     */
31 2
    public function getFilter()
32
    {
33 2
        return $this->get('q');
34
    }
35
36
    /**
37
     * @param string $query
38
     *
39
     * @return $this
40
     */
41 2
    public function setFilter($query)
42
    {
43 2
        $this->set('q', $query);
44
45 2
        return $this;
46
    }
47
48
    /**
49
     * @param $lang
50
     *
51
     * @return self
52
     */
53 1
    public function setLang($lang)
54
    {
55 1
        $this->set('lang', $lang);
56
57 1
        return $this;
58
    }
59
60
    /**
61
     * @return string
62
     */
63 1
    public function getLang()
64
    {
65 1
        return $this->get('lang');
66
    }
67
68
    /**
69
     * Get column prefix of a query
70
     *
71
     * @return string
72
     */
73 2 View Code Duplication
    public function getFilterColumn()
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...
74
    {
75 2
        $columnFilter = null;
76 2
        $query = $this->parameters['q'];
77 2
        if (false !== strpos($query, ':')) {
78 1
            $explode = explode(':', $query);
79 2
        } elseif (false !== strpos($query, '=')) {
80 1
            $explode = explode('=', $query);
81 1
        }
82 2
        if (isset($explode[0])) {
83 2
            $columnFilter = $explode[0];
84 2
        }
85
86 2
        return $columnFilter;
87
    }
88
89
    /**
90
     * @return string
91
     */
92 2 View Code Duplication
    public function getFilterValue()
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...
93
    {
94 2
        $valueFilter = $query = $this->parameters['q'];
95 2
        if (false !== strpos($query, ':')) {
96 1
            $explode = explode(':', $query);
97 2
        } elseif (false !== strpos($query, '=')) {
98 1
            $explode = explode('=', $query);
99 1
        }
100 2
        if (isset($explode[1])) {
101 2
            $valueFilter = $explode[1];
102 2
        }
103
104 2
        return $valueFilter;
105
    }
106
}
107