1 | <?php |
||
12 | abstract class AbstractQuery |
||
13 | { |
||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | private $selector; |
||
18 | |||
19 | /** |
||
20 | * @var Filters |
||
21 | */ |
||
22 | private $filters; |
||
23 | |||
24 | /** |
||
25 | * @param string $selector |
||
26 | * @param Filters $filters |
||
27 | */ |
||
28 | 1 | public function __construct($selector, Filters $filters = null) |
|
29 | { |
||
30 | 1 | $this->filters = $filters ?: new Filters(); |
|
31 | |||
32 | $this->selector = $this->filters->extractAllPatterns($selector); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @return string |
||
37 | */ |
||
38 | 1 | public function getSelector() |
|
42 | |||
43 | /** |
||
44 | * @return Filters |
||
45 | */ |
||
46 | 1 | public function getFilters() |
|
50 | |||
51 | 2 | public function __toString() |
|
52 | { |
||
53 | $reflect = new ReflectionClass($this); |
||
54 | |||
55 | return sprintf('[%s: %s]', $reflect->getShortName(), $this->selector); |
||
56 | 2 | } |
|
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | abstract public function getXPath(); |
||
62 | |||
63 | } |
||
64 |