1 | <?php |
||
7 | class Parser implements ParserContract |
||
8 | { |
||
9 | /** |
||
10 | * Default search weight. |
||
11 | * |
||
12 | * @var integer |
||
13 | */ |
||
14 | protected $weight; |
||
15 | |||
16 | /** |
||
17 | * Wildcard token. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $wildcard; |
||
22 | |||
23 | /** |
||
24 | * Create new parser instance. |
||
25 | * |
||
26 | * @param integer $weight |
||
27 | */ |
||
28 | public function __construct($weight = 1, $wildcard = '*') |
||
33 | |||
34 | /** |
||
35 | * Parse searchable columns. |
||
36 | * |
||
37 | * @param array|string $columns |
||
38 | * @return array |
||
39 | */ |
||
40 | public function parseWeights($columns) |
||
48 | |||
49 | /** |
||
50 | * Add search weight to the columns if missing. |
||
51 | * |
||
52 | * @param array $columns |
||
53 | */ |
||
54 | protected function addMissingWeights(array $columns) |
||
68 | |||
69 | /** |
||
70 | * Strip wildcard tokens from the word. |
||
71 | * |
||
72 | * @param string $word |
||
73 | * @return string |
||
74 | */ |
||
75 | public function stripWildcards($word) |
||
79 | |||
80 | /** |
||
81 | * Parse query string into separate words with wildcards if applicable. |
||
82 | * |
||
83 | * @param string $query |
||
84 | * @param boolean $fulltext |
||
85 | * @return array |
||
86 | */ |
||
87 | public function parseQuery($query, $fulltext = true) |
||
97 | |||
98 | /** |
||
99 | * Split query string into words/phrases to be searched. |
||
100 | * |
||
101 | * @param string $query |
||
102 | * @return array |
||
103 | */ |
||
104 | protected function splitString($query) |
||
110 | |||
111 | /** |
||
112 | * Add wildcard tokens to the words. |
||
113 | * |
||
114 | * @param array $words |
||
115 | */ |
||
116 | protected function addWildcards(array $words) |
||
124 | } |
||
125 |