@@ -6,9 +6,7 @@ |
||
6 | 6 | use Nqxcode\LuceneSearch\Search; |
7 | 7 | use Symfony\Component\Console\Helper\ProgressBar; |
8 | 8 | use Symfony\Component\Console\Output\NullOutput; |
9 | - |
|
10 | 9 | use App; |
11 | -use Config; |
|
12 | 10 | |
13 | 11 | class RebuildCommand extends Command |
14 | 12 | { |
@@ -54,7 +54,7 @@ |
||
54 | 54 | $progress = new ProgressBar($this->getOutput(), $count); |
55 | 55 | $progress->start(); |
56 | 56 | |
57 | - $modelRepository->chunk(1000, function ($chunk) use ($progress, $search) { |
|
57 | + $modelRepository->chunk(1000, function($chunk) use ($progress, $search) { |
|
58 | 58 | foreach ($chunk as $model) { |
59 | 59 | $search->update($model); |
60 | 60 | $progress->advance(); |
@@ -19,11 +19,17 @@ |
||
19 | 19 | $this->delete($model->id, $this->uid); |
20 | 20 | } |
21 | 21 | |
22 | + /** |
|
23 | + * @param Model $model |
|
24 | + */ |
|
22 | 25 | private function filterFields($model) |
23 | 26 | { |
24 | 27 | return $this->filterKeysFromArray($model->attributesToArray(), $model::getSearchFields()); |
25 | 28 | } |
26 | 29 | |
30 | + /** |
|
31 | + * @param Model $model |
|
32 | + */ |
|
27 | 33 | private function filterParameters($model) |
28 | 34 | { |
29 | 35 | if (! empty($model::getSearchParameters())) { |
@@ -26,11 +26,11 @@ |
||
26 | 26 | |
27 | 27 | private function filterParameters($model) |
28 | 28 | { |
29 | - if (! empty($model::getSearchParameters())) { |
|
29 | + if (!empty($model::getSearchParameters())) { |
|
30 | 30 | return $this->filterKeysFromArray($model->attributesToArray(), $model::getSearchParameters()); |
31 | 31 | } |
32 | 32 | |
33 | - return []; |
|
33 | + return [ ]; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * @param $limit |
|
42 | + * @param integer $limit |
|
43 | 43 | * @return $this |
44 | 44 | */ |
45 | 45 | public function limit($limit) |
@@ -79,7 +79,6 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | - * @param bool $path |
|
83 | 82 | * @return string |
84 | 83 | * @throws \Exception |
85 | 84 | */ |
@@ -85,7 +85,7 @@ |
||
85 | 85 | */ |
86 | 86 | protected function path() |
87 | 87 | { |
88 | - if (! $this->path ) { |
|
88 | + if (!$this->path) { |
|
89 | 89 | throw new \Exception('No path specified nor config variable set.'); |
90 | 90 | } |
91 | 91 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * Search constructor. |
23 | 23 | * @param Index $index |
24 | - * @param \BestServedCold\LaravelZendSearch\Query $query |
|
24 | + * @param Query $query |
|
25 | 25 | */ |
26 | 26 | public function __construct(Index $index, Query $query) |
27 | 27 | { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @param $string |
124 | - * @param array|bool|string $field |
|
124 | + * @param string $field |
|
125 | 125 | * @todo Work out why the search only works if the string is uppercase... |
126 | 126 | * @return $this|bool |
127 | 127 | */ |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use BestServedCold\LaravelZendSearch\Search\Wildcard; |
6 | 6 | use ZendSearch\Lucene\Index\Term; |
7 | -use ZendSearch\Lucene\Search\Query\AbstractQuery; |
|
8 | 7 | use ZendSearch\Lucene\Search\Query\Fuzzy; |
9 | 8 | use ZendSearch\Lucene\Search\Query\MultiTerm; |
10 | 9 | use ZendSearch\Lucene\Search\Query\Phrase; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param bool $field |
115 | 115 | * @param array $options |
116 | 116 | */ |
117 | - public function wildcard($string, $field = false, $options = []) |
|
117 | + public function wildcard($string, $field = false, $options = [ ]) |
|
118 | 118 | { |
119 | 119 | $this->query->add((new Wildcard($field, $string, $options))->get()); |
120 | 120 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | private function mapWhereArray($string, array $array) |
161 | 161 | { |
162 | - return array_map(function () use ($string) { |
|
162 | + return array_map(function() use ($string) { |
|
163 | 163 | return $string; |
164 | 164 | }, array_flip($array)); |
165 | 165 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | private function mapIds(array $array) |
191 | 191 | { |
192 | - return array_map(function ($v) { |
|
192 | + return array_map(function($v) { |
|
193 | 193 | return $v->id; |
194 | 194 | }, $array); |
195 | 195 | } |
@@ -8,6 +8,9 @@ |
||
8 | 8 | protected $field = false; |
9 | 9 | protected $Options = []; |
10 | 10 | |
11 | + /** |
|
12 | + * @param boolean $string |
|
13 | + */ |
|
11 | 14 | public function __construct($string, $field = false, $options = []) |
12 | 15 | { |
13 | 16 | $this->string = $string; |
@@ -6,9 +6,9 @@ |
||
6 | 6 | { |
7 | 7 | protected $string; |
8 | 8 | protected $field = false; |
9 | - protected $Options = []; |
|
9 | + protected $Options = [ ]; |
|
10 | 10 | |
11 | - public function __construct($string, $field = false, $options = []) |
|
11 | + public function __construct($string, $field = false, $options = [ ]) |
|
12 | 12 | { |
13 | 13 | $this->string = $string; |
14 | 14 | $this->field = $field; |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * @param $id |
50 | 50 | * @param array $fields fields that are indexed |
51 | 51 | * @param array $parameters fields that aren't indexed |
52 | - * @param boolean|int $uid unique identifier, if required |
|
52 | + * @param boolean|string $uid unique identifier, if required |
|
53 | 53 | * @return mixed |
54 | 54 | */ |
55 | 55 | public function insert($id, array $fields, array $parameters = [], $uid = false) |
@@ -52,7 +52,7 @@ |
||
52 | 52 | * @param boolean|int $uid unique identifier, if required |
53 | 53 | * @return mixed |
54 | 54 | */ |
55 | - public function insert($id, array $fields, array $parameters = [], $uid = false) |
|
55 | + public function insert($id, array $fields, array $parameters = [ ], $uid = false) |
|
56 | 56 | { |
57 | 57 | $this->document->addField($this->field('xref_id', $id)); |
58 | 58 | $this->document->addField($this->field('_parameters', $this->flattenParameters($parameters), 'unIndexed')); |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | |
8 | 8 | trait SearchTrait |
9 | 9 | { |
10 | - private static $searchFields = []; |
|
11 | - private static $searchParameters = []; |
|
10 | + private static $searchFields = [ ]; |
|
11 | + private static $searchParameters = [ ]; |
|
12 | 12 | |
13 | 13 | private static function setup() |
14 | 14 | { |
15 | - if (! is_subclass_of(static::class, Model::class)) { |
|
15 | + if (!is_subclass_of(static::class, Model::class)) { |
|
16 | 16 | throw new \Exception( |
17 | 17 | 'SearchTrait must only be used with Eloquent models, [' . get_called_class() . '] used' |
18 | 18 | ); |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | $store = App::make(Store::class); |
64 | 64 | |
65 | 65 | self::saved( |
66 | - function (Model $model) use ($store) { |
|
66 | + function(Model $model) use ($store) { |
|
67 | 67 | self::insertCallback($model, $store); |
68 | 68 | } |
69 | 69 | ); |
70 | 70 | |
71 | 71 | self::deleting( |
72 | - function (Model $model) use ($store) { |
|
72 | + function(Model $model) use ($store) { |
|
73 | 73 | self::deleteCallback($model, $store); |
74 | 74 | } |
75 | 75 | ); |
@@ -32,24 +32,24 @@ |
||
32 | 32 | __DIR__ . '/../../../config/search.php' => config_path('search.php'), |
33 | 33 | ]); |
34 | 34 | |
35 | - $this->app->singleton('command.search.rebuild', function () { |
|
35 | + $this->app->singleton('command.search.rebuild', function() { |
|
36 | 36 | return new RebuildCommand; |
37 | 37 | }); |
38 | 38 | |
39 | - $this->app->singleton('command.search.clear', function () { |
|
39 | + $this->app->singleton('command.search.clear', function() { |
|
40 | 40 | return new ClearCommand; |
41 | 41 | }); |
42 | 42 | |
43 | - $this->app->singleton('command.search.optimise', function () { |
|
43 | + $this->app->singleton('command.search.optimise', function() { |
|
44 | 44 | return new OptimiseCommand; |
45 | 45 | }); |
46 | 46 | |
47 | - $this->commands(['command.search.rebuild', 'command.search.optimise', 'command.search.clear']); |
|
47 | + $this->commands([ 'command.search.rebuild', 'command.search.optimise', 'command.search.clear' ]); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
51 | 51 | public function provides() |
52 | 52 | { |
53 | - return ['search', 'command.search.rebuild', 'command.search.optimise', 'command.search.clear']; |
|
53 | + return [ 'search', 'command.search.rebuild', 'command.search.optimise', 'command.search.clear' ]; |
|
54 | 54 | } |
55 | 55 | } |
@@ -58,7 +58,7 @@ |
||
58 | 58 | * @param array $parameters |
59 | 59 | * @return mixed |
60 | 60 | */ |
61 | - public function insert($id, array $fields, array $parameters = [], $uid = false) |
|
61 | + public function insert($id, array $fields, array $parameters = [ ], $uid = false) |
|
62 | 62 | { |
63 | 63 | $this->delete($id, $uid); |
64 | 64 | return $this->insert->insert($id, $fields, $parameters, $uid ?: $this->uid); |