Passed
Push — master ( ebcd1a...0e387b )
by Timo
04:23
created

QueryGroupFacetQueryBuilder::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
crap 2.0185
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 28
     */
27
    public function build($facetName, TypoScriptConfiguration $configuration)
28 28
    {
29 28
        $facetParameters = [];
30
        $facetConfiguration = $configuration->getSearchFacetingFacetByName($facetName);
31 28
        foreach ($facetConfiguration['queryGroup.'] as $queryName => $queryConfiguration) {
32 28
            $tags = $this->buildExcludeTags($facetConfiguration, $configuration);
33 28
            $facetParameters['facet.query'][] = $tags . $facetConfiguration['field'] . ':' . $queryConfiguration['query'];
34
        }
35
36
        return $facetParameters;
37
    }
38
}
39