Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
83.33% |
5 / 6 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
| WildcardNode | |
83.33% |
5 / 6 |
|
75.00% |
3 / 4 |
4.07 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getWildcardQuery | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| accept | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace CirrusSearch\Parser\AST; |
| 4 | |
| 5 | use CirrusSearch\Parser\AST\Visitor\Visitor; |
| 6 | |
| 7 | /** |
| 8 | * Wildcard query |
| 9 | */ |
| 10 | class WildcardNode extends ParsedNode { |
| 11 | |
| 12 | /** |
| 13 | * @var string |
| 14 | */ |
| 15 | private $wildcardQuery; |
| 16 | |
| 17 | /** |
| 18 | * @param int $startOffset |
| 19 | * @param int $endOffset |
| 20 | * @param string $wildcard the wildcard query (should remain as written by the user) |
| 21 | */ |
| 22 | public function __construct( $startOffset, $endOffset, $wildcard ) { |
| 23 | parent::__construct( $startOffset, $endOffset ); |
| 24 | $this->wildcardQuery = $wildcard; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * @return array |
| 29 | */ |
| 30 | public function toArray() { |
| 31 | return [ 'wildcard' => array_merge( parent::baseParams(), |
| 32 | [ 'wildcardquery' => $this->wildcardQuery ] ) ]; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * The wildcard query. |
| 37 | * Beware that it may contain potentially slow queries: |
| 38 | * - leading wildcards |
| 39 | * - non negligible number of wildcards |
| 40 | * @return string |
| 41 | */ |
| 42 | public function getWildcardQuery() { |
| 43 | return $this->wildcardQuery; |
| 44 | } |
| 45 | |
| 46 | public function accept( Visitor $visitor ) { |
| 47 | $visitor->visitWildcardNode( $this ); |
| 48 | } |
| 49 | } |