Completed
Push — master ( ee56eb...1eb78b )
by Juuso
04:46
created
src/AlgoliaComponent.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
      */
43 43
     public function bootstrap($app)
44 44
     {
45
-        Yii::$container->set(AlgoliaManager::class, function () {
45
+        Yii::$container->set(AlgoliaManager::class, function() {
46 46
              return $this->createManager();
47 47
         });
48 48
     }
Please login to merge, or discard this patch.
src/ActiveRecord/SynchronousAutoIndexBehavior.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,21 +37,21 @@
 block discarded – undo
37 37
     public function events()
38 38
     {
39 39
         return [
40
-            ActiveRecord::EVENT_AFTER_INSERT => function (Event $event) {
40
+            ActiveRecord::EVENT_AFTER_INSERT => function(Event $event) {
41 41
                 if ($this->afterInsert) {
42 42
                     /** @var $manager AlgoliaManager */
43 43
                     $manager = Yii::$container->get(AlgoliaManager::class);
44 44
                     $manager->pushToIndices($event->sender);
45 45
                 }
46 46
             },
47
-            ActiveRecord::EVENT_AFTER_DELETE => function (Event $event) {
47
+            ActiveRecord::EVENT_AFTER_DELETE => function(Event $event) {
48 48
                 if ($this->afterDelete) {
49 49
                     /** @var $manager AlgoliaManager */
50 50
                     $manager = Yii::$container->get(AlgoliaManager::class);
51 51
                     $manager->removeFromIndices($event->sender);
52 52
                 }
53 53
             },
54
-            ActiveRecord::EVENT_AFTER_UPDATE => function (Event $event) {
54
+            ActiveRecord::EVENT_AFTER_UPDATE => function(Event $event) {
55 55
                 if ($this->afterUpdate) {
56 56
                     /** @var $manager AlgoliaManager */
57 57
                     $manager = Yii::$container->get(AlgoliaManager::class);
Please login to merge, or discard this patch.
src/ActiveRecord/ActiveRecordFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
      */
16 16
     public function make($className)
17 17
     {
18
-        if (! (new \ReflectionClass($className))->implementsInterface(ActiveRecordInterface::class)) {
18
+        if ( ! (new \ReflectionClass($className))->implementsInterface(ActiveRecordInterface::class)) {
19 19
             throw new \InvalidArgumentException("Cannot initiate a class ({$className}) which doesn't implement \\yii\\db\\ActiveRecordInterface");
20 20
         }
21 21
 
Please login to merge, or discard this patch.
src/AlgoliaFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
      */
34 34
     public function makeSearchableObject($className)
35 35
     {
36
-        if (! (new \ReflectionClass($className))->implementsInterface(SearchableInterface::class)) {
36
+        if ( ! (new \ReflectionClass($className))->implementsInterface(SearchableInterface::class)) {
37 37
             throw new \InvalidArgumentException("Cannot initiate a class ({$className}) which doesn't implement leinonen\\Yii2Algolia\\SearchableInterface");
38 38
         }
39 39
 
Please login to merge, or discard this patch.
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.