Completed
Push — master ( 3e8b02...37f80c )
by Florian
16:58
created
Services/Mapping/DocumentToEntityMapper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@
 block discarded – undo
34 34
 	public function getEntity(Document $document) {
35 35
 		$clazz = $document->getEntityClass();
36 36
 		
37
-		if($clazz == null) {
37
+		if ($clazz == null) {
38 38
 			return null;
39 39
 		}
40
-		if(!$document->getEntityId()) {
40
+		if (!$document->getEntityId()) {
41 41
 			return null;
42 42
 		}
43 43
 		return $this->managerRegistry->getManagerForClass($clazz)->getRepository($clazz)->find($document->getEntityId());
Please login to merge, or discard this patch.
Tests/application.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 // application.php
3
-require __DIR__ . '/../vendor/autoload.php';
3
+require __DIR__.'/../vendor/autoload.php';
4 4
 
5 5
 use StingerSoft\EntitySearchBundle\Command\ClearIndexCommand;
6 6
 use StingerSoft\EntitySearchBundle\Command\SyncCommand;
Please login to merge, or discard this patch.
Tests/Command/SyncCommandTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,8 +43,8 @@
 block discarded – undo
43 43
 			'get' 
44 44
 		))->disableOriginalConstructor()->getMock();
45 45
 		
46
-		$container->method('get')->willReturnCallback(function ($serviceId) use ($that) {
47
-			switch($serviceId) {
46
+		$container->method('get')->willReturnCallback(function($serviceId) use ($that) {
47
+			switch ($serviceId) {
48 48
 				case 'kernel':
49 49
 					return $that;
50 50
 				case 'doctrine.orm.entity_manager':
Please login to merge, or discard this patch.
Model/Query.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	 * @return \Pec\Bundle\MtuDvpBundle\Entity\TestRiskValue
91 91
 	 */
92 92
 	public function __get($name) {
93
-		if(strrpos($name, 'facet_', -strlen($name)) !== false) {
93
+		if (strrpos($name, 'facet_', -strlen($name)) !== false) {
94 94
 			$facetname = substr($name, 6);
95 95
 			
96
-			if(isset($this->facets[$facetname])) {
96
+			if (isset($this->facets[$facetname])) {
97 97
 				return $this->facets[$facetname];
98 98
 			}
99 99
 			return array();
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	 *        	The value of the property
109 109
 	 */
110 110
 	public function __set($name, $value) {
111
-		if(strrpos($name, 'facet_', -strlen($name)) !== false) {
111
+		if (strrpos($name, 'facet_', -strlen($name)) !== false) {
112 112
 			$facetname = substr($name, 6);
113 113
 			
114
-			if(!isset($this->facets[$facetname])) {
114
+			if (!isset($this->facets[$facetname])) {
115 115
 				$this->facets[$facetname] = array();
116 116
 			}
117 117
 			$this->facets[$facetname] = $value;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 * @return boolean
126 126
 	 */
127 127
 	public function __isset($name) {
128
-		if(strrpos($name, 'facet_', -strlen($name)) !== false) {
128
+		if (strrpos($name, 'facet_', -strlen($name)) !== false) {
129 129
 			return true;
130 130
 		}
131 131
 		
Please login to merge, or discard this patch.
Services/Mapping/EntityToDocumentMapper.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -47,18 +47,18 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function __construct(SearchService $searchService, array $mapping = array()) {
49 49
 		$this->searchService = $searchService;
50
-		foreach($mapping as $key => $config) {
51
-			if(!isset($config['mappings'])) {
52
-				throw new \InvalidArgumentException($key . ' has no mapping defined!');
50
+		foreach ($mapping as $key => $config) {
51
+			if (!isset($config['mappings'])) {
52
+				throw new \InvalidArgumentException($key.' has no mapping defined!');
53 53
 			}
54
-			if(!isset($config['persistence'])) {
55
-				throw new \InvalidArgumentException($key . ' has no persistence defined!');
54
+			if (!isset($config['persistence'])) {
55
+				throw new \InvalidArgumentException($key.' has no persistence defined!');
56 56
 			}
57
-			if(!isset($config['persistence']['model'])) {
58
-				throw new \InvalidArgumentException($key . ' has no model defined!');
57
+			if (!isset($config['persistence']['model'])) {
58
+				throw new \InvalidArgumentException($key.' has no model defined!');
59 59
 			}
60 60
 			$map = array();
61
-			foreach($config['mappings'] as $fieldKey => $fieldConfig) {
61
+			foreach ($config['mappings'] as $fieldKey => $fieldConfig) {
62 62
 				$map[$fieldKey] = isset($fieldConfig['propertyPath']) && $fieldConfig['propertyPath'] ? $fieldConfig['propertyPath'] : $fieldKey;
63 63
 			}
64 64
 			
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 	 * @see \StingerSoft\EntitySearchBundle\Services\Mapping\EntityToDocumentMapperInterface::isIndexable()
74 74
 	 */
75 75
 	public function isIndexable($object) {
76
-		if($object instanceof SearchableEntity) {
76
+		if ($object instanceof SearchableEntity) {
77 77
 			return true;
78 78
 		}
79
-		if(count($this->getMapping(get_class($object))) > 0) {
79
+		if (count($this->getMapping(get_class($object))) > 0) {
80 80
 			return true;
81 81
 		}
82 82
 		return false;
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function isClassIndexable($clazz) {
92 92
 		$reflectionClass = new \ReflectionClass($clazz);
93
-		if(array_key_exists(SearchableEntity::class, $reflectionClass->getInterfaces())) {
93
+		if (array_key_exists(SearchableEntity::class, $reflectionClass->getInterfaces())) {
94 94
 			return true;
95 95
 		}
96
-		if(count($this->getMapping($clazz)) > 0) {
96
+		if (count($this->getMapping($clazz)) > 0) {
97 97
 			return true;
98 98
 		}
99 99
 		return false;
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 	 * @see \StingerSoft\EntitySearchBundle\Services\Mapping\EntityToDocumentMapperInterface::createDocument()
106 106
 	 */
107 107
 	public function createDocument(ObjectManager $manager, $object) {
108
-		if(!$this->isIndexable($object))
108
+		if (!$this->isIndexable($object))
109 109
 			return false;
110 110
 		$document = $this->getSearchService($manager)->createEmptyDocumentFromEntity($object);
111 111
 		$index = $this->fillDocument($document, $object);
112
-		if($index == false)
112
+		if ($index == false)
113 113
 			return false;
114 114
 		
115 115
 		return $document;
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 	 * @return boolean
124 124
 	 */
125 125
 	protected function fillDocument(Document &$document, $object) {
126
-		if($object instanceof SearchableEntity) {
126
+		if ($object instanceof SearchableEntity) {
127 127
 			return $object->indexEntity($document);
128 128
 		}
129 129
 		$mapping = $this->getMapping(get_class($object));
130 130
 		$accessor = PropertyAccess::createPropertyAccessor();
131
-		foreach($mapping as $fieldName => $propertyPath) {
131
+		foreach ($mapping as $fieldName => $propertyPath) {
132 132
 			$document->addField($fieldName, $accessor->getValue($object, $propertyPath));
133 133
 		}
134 134
 		return true;
@@ -141,15 +141,15 @@  discard block
 block discarded – undo
141 141
 	 * @return \StingerSoft\EntitySearchBundle\Services\string[string]
142 142
 	 */
143 143
 	protected function getMapping($clazz) {
144
-		if(isset($this->cachedMapping[$clazz])) {
144
+		if (isset($this->cachedMapping[$clazz])) {
145 145
 			return $this->cachedMapping[$clazz];
146 146
 		}
147 147
 		$ref = new \ReflectionClass($clazz);
148 148
 		
149 149
 		$mapping = array();
150 150
 		
151
-		foreach($this->mapping as $className => $config) {
152
-			if($clazz == $className || $ref->isSubclassOf($className)) {
151
+		foreach ($this->mapping as $className => $config) {
152
+			if ($clazz == $className || $ref->isSubclassOf($className)) {
153 153
 				$mapping = array_merge($mapping, $config);
154 154
 			}
155 155
 		}
Please login to merge, or discard this patch.
DependencyInjection/StingerSoftEntitySearchExtension.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
 
35 35
 		$container->setParameter('stinger_soft.entity_search.available_facets', $config['facets']);
36 36
 
37
-		$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
37
+		$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
38 38
 		$loader->load('services.yml');
39 39
 		
40 40
 		$entityToDocumentMapperDefinition = $container->getDefinition(EntityToDocumentMapperInterface::SERVICE_ID);
Please login to merge, or discard this patch.
Controller/SearchControllerTrait.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
 
39 39
 	public function searchAction(Request $request) {
40
-		if($request->query->get('term', false) !== false) {
40
+		if ($request->query->get('term', false) !== false) {
41 41
 			$this->setSearchTerm($request->getSession(), $request->query->get('term'));
42 42
 			return $this->redirectToRoute('stinger_soft_entity_search_search');
43 43
 		}
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 		));
54 54
 
55 55
 		$facetForm->handleRequest($request);
56
-		if($facetForm->isSubmitted()) {
57
-			if($facetForm->get('clear')->isClicked()) {
56
+		if ($facetForm->isSubmitted()) {
57
+			if ($facetForm->get('clear')->isClicked()) {
58 58
 				$query->setFacets($this->getDefaultFacets());
59 59
 			}
60 60
 			$this->setSearchTerm($request->getSession(), $query->getSearchTerm());
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 		$page = $request->query->get('page', 1);
72 72
 		$results = array();
73
-		if($result instanceof PaginatableResultSet) {
73
+		if ($result instanceof PaginatableResultSet) {
74 74
 			$results = $result->paginate($page, $this->getResultsPerPage());
75 75
 		} else {
76 76
 			$results = $result->getResults(($page - 1) * $this->getResultsPerPage(), $this->getResultsPerPage());
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	protected function getConfiguredUsedFacets(array $queryUsedFacets) {
89 89
 		$availableFacets = $this->getAvailableFacets();
90 90
 		$usedFacets = array();
91
-		foreach($queryUsedFacets as $queryUsedFacet) {
91
+		foreach ($queryUsedFacets as $queryUsedFacet) {
92 92
 			$usedFacets[$queryUsedFacet] = $availableFacets[$queryUsedFacet];
93 93
 		}
94 94
 		return $usedFacets;
@@ -152,16 +152,16 @@  discard block
 block discarded – undo
152 152
 
153 153
 
154 154
 	protected function initFacets() {
155
-		if(!$this->availableFacets) {
155
+		if (!$this->availableFacets) {
156 156
 			$this->availableFacets = array();
157 157
 			$this->facetFormatter = array();
158 158
 
159 159
 			$facetServices = $this->getParameter('stinger_soft.entity_search.available_facets');
160
-			foreach($facetServices as $facetServiceId) {
160
+			foreach ($facetServices as $facetServiceId) {
161 161
 				/** @var FacetServiceInterface $facetService */
162 162
 				$facetService = $this->get($facetServiceId);
163 163
 				$this->availableFacets[$facetService->getField()] = $facetService->getFormOptions();
164
-				if($facetService->getFacetFormatter()) {
164
+				if ($facetService->getFacetFormatter()) {
165 165
 					$this->facetFormatter[$facetService->getField()] = $facetService->getFacetFormatter();
166 166
 				}
167 167
 			}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 * @return string[string][]
176 176
 	 */
177 177
 	protected function getSearchFacets(SessionInterface $session) {
178
-		$facets = $session->get($this->getSessionPrefix() . '_facets', false);
178
+		$facets = $session->get($this->getSessionPrefix().'_facets', false);
179 179
 		return $facets ? json_decode($facets, true) : $this->getDefaultFacets();
180 180
 	}
181 181
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @param string[string][] $facets
187 187
 	 */
188 188
 	protected function setSearchFacets(SessionInterface $session, $facets) {
189
-		$session->set($this->getSessionPrefix() . '_facets', json_encode($facets));
189
+		$session->set($this->getSessionPrefix().'_facets', json_encode($facets));
190 190
 	}
191 191
 
192 192
 	/**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 * @return mixed
197 197
 	 */
198 198
 	protected function getSearchTerm(SessionInterface $session) {
199
-		return $session->get($this->getSessionPrefix() . '_term', false);
199
+		return $session->get($this->getSessionPrefix().'_term', false);
200 200
 	}
201 201
 
202 202
 	/**
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 * @param string $term
207 207
 	 */
208 208
 	protected function setSearchTerm(SessionInterface $session, $term) {
209
-		$session->set($this->getSessionPrefix() . '_term', $term);
209
+		$session->set($this->getSessionPrefix().'_term', $term);
210 210
 	}
211 211
 
212 212
 	/**
Please login to merge, or discard this patch.
Command/SyncCommand.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	protected function execute(InputInterface $input, OutputInterface $output) {
71 71
 		// Detect upload path
72
-		if(!self::$defaultUploadPath) {
72
+		if (!self::$defaultUploadPath) {
73 73
 			$root = $this->getContainer()->get('kernel')->getRootDir();
74
-			self::$defaultUploadPath = $root . '/../web/uploads';
74
+			self::$defaultUploadPath = $root.'/../web/uploads';
75 75
 		}
76 76
 
77 77
 		// Get the entity argument
78 78
 		$entity = $input->getArgument('entity');
79 79
 
80
-		if($entity == 'all') {
80
+		if ($entity == 'all') {
81 81
 			/**
82 82
 			 * @var EntityManager $entityManager
83 83
 			 */
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
 			/**
94 94
 			 * @var ClassMetadata $m
95 95
 			 */
96
-			foreach($meta as $m) {
96
+			foreach ($meta as $m) {
97 97
 
98
-				if($m->getReflectionClass()->isAbstract() || $m->getReflectionClass()->isInterface()) {
98
+				if ($m->getReflectionClass()->isAbstract() || $m->getReflectionClass()->isInterface()) {
99 99
 					continue;
100 100
 				}
101
-				if(!$mapper->isClassIndexable($m->getReflectionClass()->getName())) {
101
+				if (!$mapper->isClassIndexable($m->getReflectionClass()->getName())) {
102 102
 					continue;
103 103
 				}
104 104
 				$this->indexEntity($input, $output, $m->getReflectionClass()->getName());
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		try {
120 120
 			// Get repository for the given entity type
121 121
 			$repository = $entityManager->getRepository($entity);
122
-		} catch(\Exception $e) {
122
+		} catch (\Exception $e) {
123 123
 			$output->writeln(sprintf('<error>No repository found for "%s", check your input</error>', $entity));
124 124
 			return;
125 125
 		}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		$useBatch = !($entityManager->getConnection()->getDatabasePlatform() instanceof SQLServerPlatform);
133 133
 
134 134
 		$iterableResult = $useBatch ? $queryBuilder->getQuery()->iterate() : $queryBuilder->getQuery()->getResult();
135
-		if($entityCount == 0) {
135
+		if ($entityCount == 0) {
136 136
 			$output->writeln('<comment>No entities found for indexing</comment>');
137 137
 			return;
138 138
 		}
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
 		$entitiesIndexed = 0;
141 141
 
142 142
 		// Index each entity separate
143
-		foreach($iterableResult as $row) {
143
+		foreach ($iterableResult as $row) {
144 144
 			$entity = $useBatch ? $row[0] : $row;
145
-			if($this->getEntityToDocumentMapper()->isIndexable($entity)) {
145
+			if ($this->getEntityToDocumentMapper()->isIndexable($entity)) {
146 146
 				$document = $this->getEntityToDocumentMapper()->createDocument($entityManager, $entity);
147
-				if($document === false) continue;
147
+				if ($document === false) continue;
148 148
 				try {
149 149
 					$this->getSearchService($entityManager)->saveDocument($document);
150 150
 					$entitiesIndexed++;
151
-				} catch(\Exception $e) {
152
-					$output->writeln('<error>Failed to index entity with ID ' . $document->getEntityId() . '</error>');
151
+				} catch (\Exception $e) {
152
+					$output->writeln('<error>Failed to index entity with ID '.$document->getEntityId().'</error>');
153 153
 				}
154
-				if($entitiesIndexed % 50 == 0) {
154
+				if ($entitiesIndexed % 50 == 0) {
155 155
 					$entityManager->flush();
156 156
 				}
157 157
 			}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		}
160 160
 		$entityManager->flush();
161 161
 		$entityManager->clear();
162
-		$output->writeln('<comment>Indexed ' . $entitiesIndexed . ' entities</comment>');
162
+		$output->writeln('<comment>Indexed '.$entitiesIndexed.' entities</comment>');
163 163
 	}
164 164
 
165 165
 	/**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @return EntityToDocumentMapperInterface
168 168
 	 */
169 169
 	protected function getEntityToDocumentMapper() {
170
-		if(!$this->entityToDocumentMapper) {
170
+		if (!$this->entityToDocumentMapper) {
171 171
 			$this->entityToDocumentMapper = $this->getContainer()->get(EntityToDocumentMapperInterface::SERVICE_ID);
172 172
 		}
173 173
 		return $this->entityToDocumentMapper;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @return SearchService
179 179
 	 */
180 180
 	protected function getSearchService(ObjectManager $manager) {
181
-		if(!$this->searchService) {
181
+		if (!$this->searchService) {
182 182
 			$this->searchService = $this->getContainer()->get(SearchService::SERVICE_ID);
183 183
 		}
184 184
 		$this->searchService->setObjectManager($manager);
Please login to merge, or discard this patch.
Form/QueryType.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -53,26 +53,26 @@  discard block
 block discarded – undo
53 53
 		$maxChoiceGroupCount = $options['max_choice_group_count'];
54 54
 		$data = array();
55 55
 		
56
-		if($usedFacets && !$result) {
56
+		if ($usedFacets && !$result) {
57 57
 			$data = array();
58
-			foreach($usedFacets as $facetType => $facetTypeOptions) {
58
+			foreach ($usedFacets as $facetType => $facetTypeOptions) {
59 59
 				$facetTypeOptions = is_array($facetTypeOptions) ? $facetTypeOptions : [];
60 60
 				$preferredChoices = $preferredFilterChoices[$facetType] ?? [];
61 61
 				$i = 0;
62
-				$builder->add('facet_' . $facetType, FacetType::class, array_merge(array(
63
-					'label' => 'stinger_soft_entity_search.forms.query.' . $facetType . '.label',
62
+				$builder->add('facet_'.$facetType, FacetType::class, array_merge(array(
63
+					'label' => 'stinger_soft_entity_search.forms.query.'.$facetType.'.label',
64 64
 					'multiple' => true,
65 65
 					'expanded' => true,
66 66
 					'allow_extra_fields' => true,
67
-					'preferred_choices' => function ($val) use ($preferredChoices, $data, $facetType, $maxChoiceGroupCount, &$i) {
68
-						return $i++ < $maxChoiceGroupCount || $maxChoiceGroupCount == 0 || in_array($val, $preferredChoices) || (isset($data['facet_' . $facetType]) && in_array($val, $data['facet_' . $facetType]));
67
+					'preferred_choices' => function($val) use ($preferredChoices, $data, $facetType, $maxChoiceGroupCount, &$i) {
68
+						return $i++ < $maxChoiceGroupCount || $maxChoiceGroupCount == 0 || in_array($val, $preferredChoices) || (isset($data['facet_'.$facetType]) && in_array($val, $data['facet_'.$facetType]));
69 69
 					} 
70 70
 				), $facetTypeOptions));
71 71
 				unset($i);
72 72
 			}
73 73
 		}
74
-		if($result) {
75
-			$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options, $result) {
74
+		if ($result) {
75
+			$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) use ($options, $result) {
76 76
 				$this->createFacets($event->getForm(), $result->getFacets(), $options, $event->getData());
77 77
 			});
78 78
 		}
@@ -111,19 +111,19 @@  discard block
 block discarded – undo
111 111
 		$selectedFacets = $data->getFacets();
112 112
 		$usedFacets = $options['used_facets'];
113 113
 		
114
-		foreach($facets->getFacets() as $facetType => $facetValues) {
114
+		foreach ($facets->getFacets() as $facetType => $facetValues) {
115 115
 			$preferredChoices = isset($preferredFilterChoices[$facetType]) ? $preferredFilterChoices[$facetType] : array();
116 116
 			
117 117
 			$i = 0;
118 118
 			$facetTypeOptions = isset($usedFacets[$facetType]) ? $usedFacets[$facetType] : [];
119 119
 			$formatter = isset($options['facet_formatter'][$facetType]) ? $options['facet_formatter'][$facetType] : null;
120
-			$builder->add('facet_' . $facetType, FacetType::class, array_merge(array(
121
-				'label' => 'stinger_soft_entity_search.forms.query.' . $facetType . '.label',
120
+			$builder->add('facet_'.$facetType, FacetType::class, array_merge(array(
121
+				'label' => 'stinger_soft_entity_search.forms.query.'.$facetType.'.label',
122 122
 				'multiple' => true,
123 123
 				'expanded' => true,
124 124
 				'allow_extra_fields' => true,
125 125
 				'choices' => $this->generateFacetChoices($facetType, $facetValues, isset($selectedFacets[$facetType]) ? $selectedFacets[$facetType] : array(), $formatter),
126
-				'preferred_choices' => function ($val) use ($preferredChoices, $selectedFacets, $facetType, $maxChoiceGroupCount, &$i) {
126
+				'preferred_choices' => function($val) use ($preferredChoices, $selectedFacets, $facetType, $maxChoiceGroupCount, &$i) {
127 127
 					return $i++ < $maxChoiceGroupCount || $maxChoiceGroupCount == 0 || in_array($val, $preferredChoices) || (isset($selectedFacets[$facetType]) && in_array($val, $selectedFacets[$facetType]));
128 128
 				} 
129 129
 			), $facetTypeOptions));
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	protected function generateFacetChoices($facetType, array $facets, array $selectedFacets = array(), $formatter) {
140 140
 		$choices = array();
141
-		foreach($facets as $facet => $count) {
142
-			if($count == 0 && !in_array($facet, $selectedFacets))
141
+		foreach ($facets as $facet => $count) {
142
+			if ($count == 0 && !in_array($facet, $selectedFacets))
143 143
 				continue;
144 144
 			$choices[$this->formatFacet($formatter, $facetType, $facet, $count)] = $facet;
145 145
 		}
146
-		foreach($selectedFacets as $facet) {
147
-			if(isset($facets[$facet])) continue;
146
+		foreach ($selectedFacets as $facet) {
147
+			if (isset($facets[$facet])) continue;
148 148
 			$count = 0;
149 149
 			$choices[$this->formatFacet($formatter, $facetType, $facet, $count)] = $facet;
150 150
 		}
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	}
153 153
 	
154 154
 	protected function formatFacet($formatter, $facetType, $facet, $count) {
155
-		$default = $facet . ' (' . $count . ')';
156
-		if(!$formatter) {
155
+		$default = $facet.' ('.$count.')';
156
+		if (!$formatter) {
157 157
 			return $default;
158 158
 		}
159 159
 		return call_user_func($formatter, $facetType, $facet, $count, $default);
Please login to merge, or discard this patch.