Passed
Branch master (2bdc71)
by Csaba
06:03 queued 04:17
created
bootstrap.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 include_once  __DIR__ . '/vendor/autoload.php';
3
-if (!is_file(__DIR__. '/clusterpoint.php')) {
4
-    copy(__DIR__. '/clusterpoint-example.php', __DIR__. '/clusterpoint.php');
3
+if (!is_file(__DIR__ . '/clusterpoint.php')) {
4
+    copy(__DIR__ . '/clusterpoint-example.php', __DIR__ . '/clusterpoint.php');
5 5
 }
6
-if (!is_file(__DIR__. '/.env')) {
7
-    copy(__DIR__. '/.env-example', __DIR__. '/.env');
6
+if (!is_file(__DIR__ . '/.env')) {
7
+    copy(__DIR__ . '/.env-example', __DIR__ . '/.env');
8 8
 }
9
-if (is_file(__DIR__. '/.env')) {
9
+if (is_file(__DIR__ . '/.env')) {
10 10
     $dotenv = new Dotenv\Dotenv(__DIR__);
11 11
     $dotenv->load();
12 12
 }
Please login to merge, or discard this patch.
clusterpoint-example.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@
 block discarded – undo
20 20
 
21 21
 return [
22 22
     'default' => [
23
-      'host' => getenv('CLUSTERPOINT_HOST'),
24
-      'account_id' => getenv('CLUSTERPOINT_ACCOUNT_ID'),
25
-      'username' => getenv('CLUSTERPOINT_USERNAME'),
26
-      'password' => getenv('CLUSTERPOINT_PASSWORD'),
27
-      'debug' => getenv('CLUSTERPOINT_DEBUG_MODE'),
23
+        'host' => getenv('CLUSTERPOINT_HOST'),
24
+        'account_id' => getenv('CLUSTERPOINT_ACCOUNT_ID'),
25
+        'username' => getenv('CLUSTERPOINT_USERNAME'),
26
+        'password' => getenv('CLUSTERPOINT_PASSWORD'),
27
+        'debug' => getenv('CLUSTERPOINT_DEBUG_MODE'),
28 28
     ],
29 29
     'development' => [
30 30
         'host' => 'https://api-eu.clusterpoint.com/v4/',
Please login to merge, or discard this patch.
src/Database/DynamoDb/RestObject.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $indexedFields = array_intersect($uniqueFields, $indexes); //Is unique and value is set and is indexed
35 35
         sort($uniqueFields);
36 36
         sort($indexedFields);
37
-        return $uniqueFields===$indexedFields;
37
+        return $uniqueFields === $indexedFields;
38 38
     }
39 39
 
40 40
     protected function scanUniqueFields($fields)
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $filter = $this->generateScanFilter($fields);
61 61
         if (property_exists($this->resource, $this->primaryKey)) {
62 62
             $marshaler = new Marshaler;
63
-            $filter['FilterExpression'] = '('.$filter['FilterExpression'].') AND #pk<>:pk';
63
+            $filter['FilterExpression'] = '(' . $filter['FilterExpression'] . ') AND #pk<>:pk';
64 64
             $filter['ExpressionAttributeNames']['#pk'] = $this->primaryKey;
65 65
             $filter['ExpressionAttributeValues'][':pk'] = $marshaler->marshalValue(
66 66
                 $this->resource->{$this->primaryKey}
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
         ];
85 85
         foreach ($fields as $field) {
86 86
             if (property_exists($this->resource, $field)) {
87
-                $ret['FilterExpression'] .= '#'.$field.'=:'.$field.' OR ';
88
-                $ret['ExpressionAttributeNames']['#'.$field] = $field;
89
-                $ret['ExpressionAttributeValues'][':'.$field] = $marshaler->marshalValue(
87
+                $ret['FilterExpression'] .= '#' . $field . '=:' . $field . ' OR ';
88
+                $ret['ExpressionAttributeNames']['#' . $field] = $field;
89
+                $ret['ExpressionAttributeValues'][':' . $field] = $marshaler->marshalValue(
90 90
                     $this->resource->{$field}
91 91
                 );
92 92
             }
@@ -130,10 +130,10 @@  discard block
 block discarded – undo
130 130
         $marshaler = new Marshaler;
131 131
         $query = [
132 132
             'TableName' => $this->database->getDatabaseName() . '-' . $this->resourceName,
133
-            'KeyConditionExpression' => '#'.$field.'=:'.$field,
133
+            'KeyConditionExpression' => '#' . $field . '=:' . $field,
134 134
             'IndexName' => $this->indexNames[$field],
135
-            'ExpressionAttributeNames' => ['#'.$field => $field],
136
-            'ExpressionAttributeValues' => [':'.$field =>  $marshaler->marshalValue(
135
+            'ExpressionAttributeNames' => ['#' . $field => $field],
136
+            'ExpressionAttributeValues' => [':' . $field =>  $marshaler->marshalValue(
137 137
                 $this->resource->{$field}
138 138
             )],
139 139
         ];
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     protected function generatePromise($client, $request)
161 161
     {
162 162
         $promise = new Promise(
163
-            function () use (&$promise, $client, $request) {
163
+            function() use (&$promise, $client, $request) {
164 164
                 $query = new Query($client, $request);
165 165
                 while ($res = $query->next()) {
166 166
                     if ($res['Count'] !== 0) {
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@
 block discarded – undo
18 18
             $client = $this->getClient();
19 19
         }
20 20
         return (new Finder($client))
21
-          ->database($this->getDatabaseName())
22
-          ->from($this->getResourceName());
21
+            ->database($this->getDatabaseName())
22
+            ->from($this->getResourceName());
23 23
     }
24 24
 
25 25
     public function validateUniqueFields()
Please login to merge, or discard this patch.
src/Database/Clusterpoint/RestObject.php 2 patches
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@  discard block
 block discarded – undo
32 32
         if ((int)$res->hits() > 0) {
33 33
             $results = json_decode($res->rawResponse())->results;
34 34
             $message = $results[0]->{$this->primaryKey} === $this->getPrimaryKeyValue() ?
35
-                'Primary key collision' :
36
-                'Unique constraint violation';
35
+                'Primary key collision' : 'Unique constraint violation';
37 36
             throw new RestException(
38 37
                 $message,
39 38
                 ['resourceName' => $this->resourceName, 'confilct' => $results[0]]
@@ -44,7 +43,7 @@  discard block
 block discarded – undo
44 43
     private function getUniqueFieldQuery($query, $uniqueFields)
45 44
     {
46 45
         // @codeCoverageIgnoreStart
47
-        $query->where(function ($query) use ($uniqueFields) {
46
+        $query->where(function($query) use ($uniqueFields) {
48 47
             foreach ($uniqueFields as $fieldName) {
49 48
                 if (property_exists($this->resource, $fieldName)) {
50 49
                     $query->orWhere($fieldName, '==', $this->resource->{$fieldName});
@@ -57,7 +56,7 @@  discard block
 block discarded – undo
57 56
 
58 57
     public function query()
59 58
     {
60
-        $query = $this->database->getClient()->database($this->database->getDatabaseName().'.'.$this->resourceName);
59
+        $query = $this->database->getClient()->database($this->database->getDatabaseName() . '.' . $this->resourceName);
61 60
         return $query;
62 61
     }
63 62
 }
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@
 block discarded – undo
18 18
             $client = $this->getClient();
19 19
         }
20 20
         return (new Finder($client))
21
-          ->database($this->getDatabaseName())
22
-          ->from($this->getResourceName());
21
+            ->database($this->getDatabaseName())
22
+            ->from($this->getResourceName());
23 23
     }
24 24
 
25 25
     public function validateUniqueFields()
Please login to merge, or discard this patch.
src/Database/Clusterpoint/Finder.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@
 block discarded – undo
40 40
 
41 41
     protected function addWhereGroup($collection, $conditions, $logical)
42 42
     {
43
-      /**
44
-      * @codeCoverageIgnore
45
-      * Passing anonymous function to Clusterpoint API
46
-      */
43
+        /**
44
+         * @codeCoverageIgnore
45
+         * Passing anonymous function to Clusterpoint API
46
+         */
47 47
         return function ($collection) use ($conditions, $logical) {
48 48
             $this->parseWhere($collection, $conditions, $logical);
49 49
         };
Please login to merge, or discard this patch.
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -42,6 +42,9 @@  discard block
 block discarded – undo
42 42
         }
43 43
     }
44 44
 
45
+    /**
46
+     * @param \Clusterpoint\Instance\Service $collection
47
+     */
45 48
     protected function configQuery($collection)
46 49
     {
47 50
         $this->setLimit($collection);
@@ -90,6 +93,9 @@  discard block
 block discarded – undo
90 93
         };
91 94
     }
92 95
 
96
+    /**
97
+     * @param string $nextLogical
98
+     */
93 99
     protected function parseWhereGroup($logical, $collection, $condition, $nextLogical)
94 100
     {
95 101
         if ($logical === '||') {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
             );
61 61
         }
62 62
         $collection = $this->client->database(
63
-            $this->queryConfiguration->databaseName.
64
-            '.'.
63
+            $this->queryConfiguration->databaseName .
64
+            '.' .
65 65
             $this->queryConfiguration->from
66 66
         );
67 67
         $this->configQuery($collection);
68 68
         $items = json_decode(json_encode($collection->get()->toArray()));
69 69
         $count = count($items);
70
-        for ($idx=0; $idx<$count; $idx++) {
70
+        for ($idx = 0; $idx < $count; $idx++) {
71 71
             $this->resultSet[] = $items[$idx];
72 72
         }
73 73
         return $this;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
       * @codeCoverageIgnore
86 86
       * Passing anonymous function to Clusterpoint API
87 87
       */
88
-        return function ($collection) use ($conditions, $logical) {
88
+        return function($collection) use ($conditions, $logical) {
89 89
             $this->parseWhere($collection, $conditions, $logical);
90 90
         };
91 91
     }
Please login to merge, or discard this patch.
src/Database/Clusterpoint/Resource.php 1 patch
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
                 $object->{$this->primaryKey};
58 58
             return $newResource;
59 59
         } catch (\Exception $ex) {
60
-            throw new RestException($ex->getMessage(), ['result'=>empty($res)?null:$res]);
60
+            throw new RestException($ex->getMessage(), ['result'=>empty($res) ?null:$res]);
61 61
         }
62 62
     }
63 63
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             $this->failOnError($res);
69 69
             return $this->toObject($res);
70 70
         } catch (\Exception $ex) {
71
-            throw new RestException($ex->getMessage(), ['result'=>empty($res)?null:$res]);
71
+            throw new RestException($ex->getMessage(), ['result'=>empty($res) ?null:$res]);
72 72
         }
73 73
     }
74 74
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
             $this->failOnError($res);
80 80
             return $this->toObject($res);
81 81
         } catch (\Exception $ex) {
82
-            throw new RestException($ex->getMessage(), ['result'=>empty($res)?null:$res]);
82
+            throw new RestException($ex->getMessage(), ['result'=>empty($res) ?null:$res]);
83 83
         }
84 84
     }
85 85
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             $this->failOnError($res);
91 91
             return $this->toObject($res);
92 92
         } catch (\Exception $ex) {
93
-            throw new RestException($ex->getMessage(), ['result'=>empty($res)?null:$res]);
93
+            throw new RestException($ex->getMessage(), ['result'=>empty($res) ?null:$res]);
94 94
         }
95 95
     }
96 96
 
@@ -100,8 +100,7 @@  discard block
 block discarded – undo
100 100
             return;
101 101
         }
102 102
         $message = $res->error()[0]->message === 'Requested document does not exist' ?
103
-            'Resource does not exist' :
104
-            'Database operation failed';
103
+            'Resource does not exist' : 'Database operation failed';
105 104
         throw new RestException(
106 105
             $message,
107 106
             [
Please login to merge, or discard this patch.
src/Database/DynamoDb/Resource.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         } catch (DynamoDbException $ex) {
120 120
             $this->throwAwsPutError($ex);
121 121
         } catch (\Exception $ex) {
122
-            throw new RestException($ex->getMessage(), ['result'=>empty($res)?null:$res]);
122
+            throw new RestException($ex->getMessage(), ['result'=>empty($res) ?null:$res]);
123 123
         }
124 124
         return $newResource;
125 125
     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             $res = $this->client->deleteItem($query);
132 132
             return $resourceId;
133 133
         } catch (\Exception $ex) {
134
-            throw new RestException($ex->getMessage(), ['result'=>empty($res)?null:$res]);
134
+            throw new RestException($ex->getMessage(), ['result'=>empty($res) ?null:$res]);
135 135
         }
136 136
     }
137 137
 }
Please login to merge, or discard this patch.