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

EmbeddingQueryNarrower::narrow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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