GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 2a1075...dd1b05 )
by Florian
03:22
created

QueryType   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 7
c 1
b 1
f 0
lcom 0
cbo 5
dl 0
loc 69
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A buildForm() 0 17 1
A createFacets() 0 11 2
A generateFacetChoices() 0 10 3
1
<?php
2
3
/*
4
 * This file is part of the Stinger Entity Search package.
5
 *
6
 * (c) Oliver Kotte <[email protected]>
7
 * (c) Florian Meyer <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
namespace StingerSoft\EntitySearchBundle\Form;
13
14
use Symfony\Component\Form\AbstractType;
15
use Symfony\Component\OptionsResolver\OptionsResolver;
16
use Symfony\Component\Form\FormBuilderInterface;
17
use Symfony\Component\Form\Extension\Core\Type\SearchType;
18
use Symfony\Component\Translation\TranslatorInterface;
19
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
20
use StingerSoft\EntitySearchBundle\Model\Result\FacetSet;
21
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
22
use StingerSoft\EntitySearchBundle\Model\Query;
23
use StingerSoft\EntitySearchBundle\Model\ResultSet;
24
25
class QueryType extends AbstractType {
26
27
	public function buildForm(FormBuilderInterface $builder, array $options) {
28
		$builder->add('term', SearchType::class, array(
29
			'label' => 'stinger_soft_entity_search.forms.query.term.label' 
30
		));
31
		/**
32
		 *
33
		 * @var ResultSet $result
34
		 */
35
		$result = $options['result'];
36
		$this->createFacets($builder, $result->getFacets());
37
		$builder->add('filter', SubmitType::class, array(
38
			'label' => 'stinger_soft_entity_search.forms.query.filter.label' 
39
		));
40
		$builder->add('clear', SubmitType::class, array(
41
			'label' => 'stinger_soft_entity_search.forms.query.clear.label' 
42
		));
43
	}
44
45
	/**
46
	 *
47
	 * @param FormBuilderInterface $builder        	
48
	 * @param FacetSet $facets        	
49
	 */
50
	protected function createFacets(FormBuilderInterface $builder, FacetSet $facets) {
51
		foreach($facets->getFacets() as $facetType => $facetValues) {
52
			$builder->add('facet_' . $facetType, ChoiceType::class, array(
53
				'label' => 'stinger_soft_entity_search.forms.query.' . $facetType . '.label',
54
				'multiple' => true,
55
				'expanded' => true,
56
				'choices_as_values' => true,
57
				'choices' => $this->generateFacetChoices($facetType, $facetValues) 
58
			));
59
		}
60
	}
61
62
	/**
63
	 *
64
	 * @param string $facetType        	
65
	 * @param array $facets        	
66
	 */
67
	protected function generateFacetChoices($facetType, array $facets) {
0 ignored issues
show
Unused Code introduced by
The parameter $facetType is not used and could be removed.

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

Loading history...
68
		$choices = array();
69
		
70
		foreach($facets as $facet => $count) {
71
			if($count == 0)
72
				break;
73
			$choices[$facet . ' (' . $count . ')'] = $facet;
74
		}
75
		return $choices;
76
	}
77
78
	/**
79
	 *
80
	 * {@inheritdoc}
81
	 *
82
	 */
83
	public function configureOptions(OptionsResolver $resolver) {
84
		$resolver->setDefault('data_class', Query::class);
85
		$resolver->setDefault('translation_domain', 'StingerSoftEntitySearchBundle');
86
		
87
		$resolver->setRequired('result', null);
0 ignored issues
show
Unused Code introduced by
The call to OptionsResolver::setRequired() has too many arguments starting with null.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
88
		$resolver->setAllowedTypes('result', ResultSet::class);
89
		
90
		$resolver->setRequired('translator');
91
		$resolver->setAllowedTypes('translator', TranslatorInterface::class);
92
	}
93
}