Completed
Push — master ( 59d977...e14570 )
by Kristof
07:01 queued 02:22
created

EmbeddingQueryNarrower   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A narrow() 0 4 1
1
<?php
2
3
namespace CultuurNet\UDB3\Search\Narrowing;
4
5
/**
6
 * Narrows down a query by embedding it into a bigger one that contains further restrictions.
7
 */
8
abstract class EmbeddingQueryNarrower implements QueryNarrowerInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    private $query;
14
15
    /**
16
     * EmbeddingQueryNarrower constructor.
17
     *
18
     * @param string $query
19
     *   The big query containing further restrictions. Should contain a placeholder %s at the location where the
20
     *   unspecific query needs to be embedded.
21
     */
22
    public function __construct(string $query)
23
    {
24
        $this->query = $query;
25
    }
26
27
    public function narrow(string $query): string
28
    {
29
        return sprintf($this->query, $query);
30
    }
31
}
32