Passed
Push — master ( efbfe4...f2d6e9 )
by Timo
23:10
created

QueryGroupFacetQueryBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 19
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 11 2
1
<?php
2
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\OptionBased\QueryGroup;
3
/*
4
 * This file is part of the TYPO3 CMS project.
5
 *
6
 * It is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License, either version 2
8
 * of the License, or any later version.
9
 *
10
 * For the full copyright and license information, please read the
11
 * LICENSE.txt file that was distributed with this source code.
12
 *
13
 * The TYPO3 project - inspiring people to share!
14
*/
15
16
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\DefaultFacetQueryBuilder;
17
use ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\FacetQueryBuilderInterface;
18
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration;
19
20
class QueryGroupFacetQueryBuilder extends DefaultFacetQueryBuilder implements FacetQueryBuilderInterface {
21
22
    /**
23
     * @param string $facetName
24
     * @param TypoScriptConfiguration $configuration
25
     * @return array
26
     */
27 30
    public function build($facetName, TypoScriptConfiguration $configuration)
28
    {
29 30
        $facetParameters = [];
30 30
        $facetConfiguration = $configuration->getSearchFacetingFacetByName($facetName);
31 30
        foreach ($facetConfiguration['queryGroup.'] as $queryName => $queryConfiguration) {
32 30
            $tags = $this->buildExcludeTags($facetConfiguration, $configuration);
33 30
            $facetParameters['facet.query'][] = $tags . $facetConfiguration['field'] . ':' . $queryConfiguration['query'];
34
        }
35
36 30
        return $facetParameters;
37
    }
38
}
39