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

QueryGroupFacetQueryBuilder::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
crap 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