Completed
Push — master ( ee56eb...1eb78b )
by Juuso
04:46
created
src/AlgoliaManager.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,6 @@
 block discarded – undo
6 6
 use AlgoliaSearch\Index;
7 7
 use leinonen\Yii2Algolia\ActiveRecord\ActiveQueryChunker;
8 8
 use leinonen\Yii2Algolia\ActiveRecord\ActiveRecordFactory;
9
-use yii\db\ActiveQuery;
10 9
 
11 10
 /**
12 11
  * @method setConnectTimeout(int $connectTimeout, int $timeout = 30, int $searchTimeout = 5)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
         $activeRecord = $this->activeRecordFactory->make($className);
235 235
         $indices = $this->initIndices($activeRecord);
236 236
 
237
-        $records =  $this->activeQueryChunker->chunk(
237
+        $records = $this->activeQueryChunker->chunk(
238 238
             $activeRecord->find(),
239 239
             500,
240
-            function ($activeRecordEntities) {
240
+            function($activeRecordEntities) {
241 241
                 return $this->getAlgoliaRecordsFromSearchableModelArray($activeRecordEntities);
242 242
             }
243 243
         );
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
         $response = [];
246 246
 
247 247
         foreach ($indices as $index) {
248
-            $temporaryIndexName = 'tmp_' . $index->indexName;
248
+            $temporaryIndexName = 'tmp_'.$index->indexName;
249 249
 
250 250
             /** @var Index $temporaryIndex */
251 251
             $temporaryIndex = $this->initIndex($temporaryIndexName);
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
     {
309 309
         $reflectionClass = new \ReflectionClass($class);
310 310
 
311
-        if (! $reflectionClass->implementsInterface(SearchableInterface::class)) {
311
+        if ( ! $reflectionClass->implementsInterface(SearchableInterface::class)) {
312 312
             throw new \InvalidArgumentException("The class: {$reflectionClass->name} doesn't implement leinonen\\Yii2Algolia\\SearchableInterface");
313 313
         }
314 314
     }
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
     {
325 325
         $indexNames = $searchableModel->getIndices();
326 326
 
327
-        $indices = array_map(function ($indexName) {
327
+        $indices = array_map(function($indexName) {
328 328
             if ($this->env !== null) {
329
-                $indexName = $this->env . '_' . $indexName;
329
+                $indexName = $this->env.'_'.$indexName;
330 330
             }
331 331
 
332 332
             return $this->initIndex($indexName);
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
         // Use the first element of the array to define what kind of models we are indexing.
348 348
         $arrayType = get_class($searchableModels[0]);
349 349
 
350
-        $algoliaRecords = array_map(function (SearchableInterface $searchableModel) use ($arrayType) {
351
-            if (! $searchableModel instanceof $arrayType) {
350
+        $algoliaRecords = array_map(function(SearchableInterface $searchableModel) use ($arrayType) {
351
+            if ( ! $searchableModel instanceof $arrayType) {
352 352
                 throw new \InvalidArgumentException('The given array should not contain multiple different classes');
353 353
             }
354 354
 
Please login to merge, or discard this patch.
src/ActiveRecord/ActiveQueryChunker.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         $records = $this->paginateRecords($query, $pageNumber, $size)->all();
24 24
         $results = [];
25 25
 
26
-        while(count($records) > 0)
26
+        while (count($records) > 0)
27 27
         {
28 28
             // On each chunk, pass the records to the callback and then let the
29 29
             // developer take care of everything within the callback. This allows to
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
             // If the results of the given callable function were an array
38 38
             // merge them into the result array which is returned at the end of the chunking.
39
-            if(is_array($callableResults)) {
39
+            if (is_array($callableResults)) {
40 40
                 $results = array_merge($results, $callableResults);
41 41
             }
42 42
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     private function paginateRecords(ActiveQueryInterface $query, $pageNumber, $count)
60 60
     {
61
-        $offset = ($pageNumber - 1) *  $count;
61
+        $offset = ($pageNumber - 1) * $count;
62 62
         $limit = $count;
63 63
 
64 64
         return $query->offset($offset)->limit($limit);
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@
 block discarded – undo
23 23
         $records = $this->paginateRecords($query, $pageNumber, $size)->all();
24 24
         $results = [];
25 25
 
26
-        while(count($records) > 0)
27
-        {
26
+        while(count($records) > 0) {
28 27
             // On each chunk, pass the records to the callback and then let the
29 28
             // developer take care of everything within the callback. This allows to
30 29
             // keep the memory low when looping through large result sets.
Please login to merge, or discard this patch.