Passed
Push — master ( 9edaa9...35a131 )
by Mikołaj
04:21
created

HasPriceBetweenQueryBuilder::buildQuery()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 3
eloc 2
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag. 
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project. 
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected]. 
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusElasticsearchPlugin\QueryBuilder;
14
15
use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface;
16
use Elastica\Query\AbstractQuery;
17
18
final class HasPriceBetweenQueryBuilder implements QueryBuilderInterface
19
{
20
    /**
21
     * @var ConcatedNameResolverInterface
22
     */
23
    private $channelPricingNameResolver;
24
25
    /**
26
     * @var string
27
     */
28
    private $pricePropertyPrefix;
29
30
    /**
31
     * @param ConcatedNameResolverInterface $channelPricingNameResolver
32
     * @param string $pricePropertyPrefix
33
     */
34
    public function __construct(ConcatedNameResolverInterface $channelPricingNameResolver, string $pricePropertyPrefix)
35
    {
36
        $this->channelPricingNameResolver = $channelPricingNameResolver;
37
        $this->pricePropertyPrefix = $pricePropertyPrefix;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function buildQuery(array $data): ?AbstractQuery
44
    {
45
        if (!$minPrice = $data[$this->pricePropertyPrefix] || !$maxPrice = $data['max_' . $this->pricePropertyPrefix]) {
0 ignored issues
show
Unused Code introduced by
The assignment to $maxPrice is dead and can be removed.
Loading history...
Comprehensibility introduced by
Consider adding parentheses for clarity. Current Interpretation: $minPrice = ($data[$this...->pricePropertyPrefix]), Probably Intended Meaning: ($minPrice = $data[$this...s->pricePropertyPrefix]
Loading history...
Unused Code introduced by
The assignment to $minPrice is dead and can be removed.
Loading history...
46
            return null;
47
        }
48
49
50
    }
51
}
52