These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the ONGR package. |
||
5 | * |
||
6 | * (c) NFQ Technologies UAB <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace ONGR\FilterManagerBundle\DependencyInjection\Filter; |
||
13 | |||
14 | use Symfony\Component\DependencyInjection\Definition; |
||
15 | |||
16 | /** |
||
17 | * Factory for choice filter. |
||
18 | */ |
||
19 | View Code Duplication | class ChoiceFilterFactory extends AbstractFilterFactory |
|
0 ignored issues
–
show
|
|||
20 | { |
||
21 | /** |
||
22 | * {@inheritdoc} |
||
23 | */ |
||
24 | protected function configure(Definition $definition, array $configuration) |
||
25 | { |
||
26 | parent::configure($definition, $configuration); |
||
27 | |||
28 | $definition->addMethodCall('setField', [$configuration['field']]); |
||
29 | $definition->addMethodCall('setShowZeroChoices', [$configuration['show_zero_choices']]); |
||
30 | |||
31 | if (isset($configuration['size'])) { |
||
32 | $definition->addMethodCall('setSize', [$configuration['size']]); |
||
33 | } |
||
34 | |||
35 | if (isset($configuration['sort']) && count($configuration['sort']) > 0) { |
||
36 | $definition->addMethodCall('setSortType', [$configuration['sort']]); |
||
37 | } |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | protected function getNamespace() |
||
44 | { |
||
45 | return 'ONGR\FilterManagerBundle\Filter\Widget\Choice\SingleTermChoice'; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | public function getName() |
||
52 | { |
||
53 | return 'choice'; |
||
54 | } |
||
55 | } |
||
56 |
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.