Completed
Push — master ( 4ef7f5...c8e8c2 )
by Juuso
03:51
created
src/ActiveRecord/Searchable.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
      * @param array $expand
18 18
      * @param bool $recursive
19 19
      */
20
-    abstract public function toArray(array $fields = [], array $expand = [], $recursive = true);
20
+    abstract public function toArray (array $fields = [], array $expand = [], $recursive = true);
21 21
 
22 22
     /**
23 23
      * @see \yii\db\BaseActiveRecord::getPrimaryKey()
24 24
      *
25 25
      * @param bool $asArray
26 26
      */
27
-    abstract public function getPrimaryKey($asArray = false);
27
+    abstract public function getPrimaryKey ($asArray = false);
28 28
 
29 29
     /**
30 30
      * An array of indices that this model uses. If none specified
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      *
33 33
      * @return array
34 34
      */
35
-    public function indices()
35
+    public function indices ()
36 36
     {
37 37
         return [];
38 38
     }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      *
43 43
      * @return array
44 44
      */
45
-    public function getIndices()
45
+    public function getIndices ()
46 46
     {
47 47
         $indices = $this->indices();
48 48
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      *
61 61
      * @return array
62 62
      */
63
-    public function getAlgoliaRecord()
63
+    public function getAlgoliaRecord ()
64 64
     {
65 65
         $record = $this->toArray();
66 66
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @return int
74 74
      */
75
-    public function getObjectID()
75
+    public function getObjectID ()
76 76
     {
77 77
         return $this->getPrimaryKey();
78 78
     }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @return array
84 84
      */
85
-    public function index()
85
+    public function index ()
86 86
     {
87 87
         $manager = $this->getAlgoliaManager();
88 88
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      *
95 95
      * @return array
96 96
      */
97
-    public function removeFromIndices()
97
+    public function removeFromIndices ()
98 98
     {
99 99
         $manager = $this->getAlgoliaManager();
100 100
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      *
107 107
      * @return array
108 108
      */
109
-    public function updateInIndices()
109
+    public function updateInIndices ()
110 110
     {
111 111
         $manager = $this->getAlgoliaManager();
112 112
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      *
119 119
      * @return array
120 120
      */
121
-    public static function reindex()
121
+    public static function reindex ()
122 122
     {
123 123
         $manager = static::getAlgoliaManager();
124 124
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      *
131 131
      * @return array
132 132
      */
133
-    public static function clearIndices()
133
+    public static function clearIndices ()
134 134
     {
135 135
         $manager = static::getAlgoliaManager();
136 136
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
      *
146 146
      * @return array
147 147
      */
148
-    public static function search($query, array $searchParameters = null)
148
+    public static function search ($query, array $searchParameters = null)
149 149
     {
150 150
         $manager = static::getAlgoliaManager();
151 151
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      * @return AlgoliaManager
159 159
      * @throws \yii\base\InvalidConfigException
160 160
      */
161
-    private static function getAlgoliaManager()
161
+    private static function getAlgoliaManager ()
162 162
     {
163 163
         return Yii::$container->get(AlgoliaManager::class);
164 164
     }
Please login to merge, or discard this patch.
src/AlgoliaManager.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      * @param ActiveRecordFactory $activeRecordFactory
81 81
      * @param ActiveQueryChunker $activeQueryChunker
82 82
      */
83
-    public function __construct(
83
+    public function __construct (
84 84
         Client $client,
85 85
         ActiveRecordFactory $activeRecordFactory,
86 86
         ActiveQueryChunker $activeQueryChunker
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      *
96 96
      * @return Client
97 97
      */
98
-    public function getClient()
98
+    public function getClient ()
99 99
     {
100 100
         return $this->client;
101 101
     }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      *
106 106
      * @param string $env
107 107
      */
108
-    public function setEnv($env)
108
+    public function setEnv ($env)
109 109
     {
110 110
         $this->env = $env;
111 111
     }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      *
116 116
      * @return null|string
117 117
      */
118
-    public function getEnv()
118
+    public function getEnv ()
119 119
     {
120 120
         return $this->env;
121 121
     }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      *
128 128
      * @return array
129 129
      */
130
-    public function pushToIndices(SearchableInterface $searchableModel)
130
+    public function pushToIndices (SearchableInterface $searchableModel)
131 131
     {
132 132
         $indices = $this->initIndices($searchableModel);
133 133
         $response = [];
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      *
148 148
      * @return array
149 149
      */
150
-    public function pushMultipleToIndices(array $searchableModels)
150
+    public function pushMultipleToIndices (array $searchableModels)
151 151
     {
152 152
         $algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels);
153 153
         $indices = $this->initIndices($searchableModels[0]);
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      *
170 170
      * @return array
171 171
      */
172
-    public function updateInIndices(SearchableInterface $searchableModel)
172
+    public function updateInIndices (SearchableInterface $searchableModel)
173 173
     {
174 174
         $indices = $this->initIndices($searchableModel);
175 175
         $response = [];
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      *
191 191
      * @return array
192 192
      */
193
-    public function updateMultipleInIndices(array $searchableModels)
193
+    public function updateMultipleInIndices (array $searchableModels)
194 194
     {
195 195
         $algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels);
196 196
         $indices = $this->initIndices($searchableModels[0]);
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      * @return array
214 214
      * @throws \InvalidArgumentException
215 215
      */
216
-    public function removeFromIndices(SearchableInterface $searchableModel)
216
+    public function removeFromIndices (SearchableInterface $searchableModel)
217 217
     {
218 218
         $indices = $indices = $this->initIndices($searchableModel);
219 219
         $response = [];
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
      * @return array
235 235
      * @throws \InvalidArgumentException
236 236
      */
237
-    public function removeMultipleFromIndices(array $searchableModels)
237
+    public function removeMultipleFromIndices (array $searchableModels)
238 238
     {
239 239
         $algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels);
240 240
         $indices = $this->initIndices($searchableModels[0]);
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
      *
260 260
      * @return array
261 261
      */
262
-    public function reindex($className)
262
+    public function reindex ($className)
263 263
     {
264 264
         $this->checkImplementsSearchableInterface($className);
265 265
         $activeRecord = $this->activeRecordFactory->make($className);
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
      * @throws \InvalidArgumentException
293 293
      * @return array
294 294
      */
295
-    public function reindexOnly(array $searchableModels)
295
+    public function reindexOnly (array $searchableModels)
296 296
     {
297 297
         $records = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels);
298 298
         $indices = $this->initIndices($searchableModels[0]);
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
      *
315 315
      * @return array
316 316
      */
317
-    public function reindexByActiveQuery(ActiveQueryInterface $activeQuery)
317
+    public function reindexByActiveQuery (ActiveQueryInterface $activeQuery)
318 318
     {
319 319
         $indices = null;
320 320
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
      * @throws \InvalidArgumentException
352 352
      * @return array
353 353
      */
354
-    public function clearIndices($className)
354
+    public function clearIndices ($className)
355 355
     {
356 356
         $this->checkImplementsSearchableInterface($className);
357 357
         $activeRecord = $this->activeRecordFactory->make($className);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
      *
377 377
      * @return array
378 378
      */
379
-    public function search($className, $query, array $searchParameters = null)
379
+    public function search ($className, $query, array $searchParameters = null)
380 380
     {
381 381
         $this->checkImplementsSearchableInterface($className);
382 382
         $activeRecord = $this->activeRecordFactory->make($className);
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
      *
401 401
      * @return mixed
402 402
      */
403
-    public function __call($method, $parameters)
403
+    public function __call ($method, $parameters)
404 404
     {
405 405
         return call_user_func_array([$this->getClient(), $method], $parameters);
406 406
     }
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
      *
411 411
      * @param string $class Either name or instance of the class to be checked.
412 412
      */
413
-    private function checkImplementsSearchableInterface($class)
413
+    private function checkImplementsSearchableInterface ($class)
414 414
     {
415 415
         $reflectionClass = new \ReflectionClass($class);
416 416
 
417
-        if (! $reflectionClass->implementsInterface(SearchableInterface::class)) {
417
+        if ( ! $reflectionClass->implementsInterface(SearchableInterface::class)) {
418 418
             throw new \InvalidArgumentException("The class: {$reflectionClass->name} doesn't implement leinonen\\Yii2Algolia\\SearchableInterface");
419 419
         }
420 420
     }
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
      *
427 427
      * @return Index[]
428 428
      */
429
-    private function initIndices(SearchableInterface $searchableModel)
429
+    private function initIndices (SearchableInterface $searchableModel)
430 430
     {
431 431
         $indexNames = $searchableModel->getIndices();
432 432
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
      *
449 449
      * @return array
450 450
      */
451
-    private function getAlgoliaRecordsFromSearchableModelArray(array $searchableModels)
451
+    private function getAlgoliaRecordsFromSearchableModelArray (array $searchableModels)
452 452
     {
453 453
         if (empty($searchableModels)) {
454 454
             throw new \InvalidArgumentException('The given array should not be empty');
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         $this->checkImplementsSearchableInterface($arrayType);
460 460
 
461 461
         $algoliaRecords = array_map(function (SearchableInterface $searchableModel) use ($arrayType) {
462
-            if (! $searchableModel instanceof $arrayType) {
462
+            if ( ! $searchableModel instanceof $arrayType) {
463 463
                 throw new \InvalidArgumentException('The given array should not contain multiple different classes');
464 464
             }
465 465
 
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
      *
481 481
      * @return mixed
482 482
      */
483
-    private function reindexAtomically(Index $index, array $algoliaRecords)
483
+    private function reindexAtomically (Index $index, array $algoliaRecords)
484 484
     {
485 485
         $temporaryIndexName = 'tmp_' . $index->indexName;
486 486
 
Please login to merge, or discard this patch.