Passed
Push — master ( e244ce...d9f030 )
by Fran
06:26
created
src/NOSQL/Models/NOSQLQuery.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         $con = NOSQLParserTrait::initConnection($model, $con);
28 28
         $collection = $con->selectCollection($model->getSchema()->name);
29 29
         $result = $collection->findOne(['_id' => new ObjectId($pk)]);
30
-        if(null !== $result) {
30
+        if (null !== $result) {
31 31
             $model->feed($result->getArrayCopy());
32 32
         } else {
33 33
             throw new ApiException(t('Document not found'), 404);
@@ -54,21 +54,21 @@  discard block
 block discarded – undo
54 54
 
55 55
         $resultSet->count = $collection->countDocuments($filters, $nosqlOptions);
56 56
 
57
-        $nosqlOptions["limit"] = (integer)(array_key_exists(Api::API_LIMIT_FIELD, $criteria) ? $criteria[Api::API_LIMIT_FIELD] : Config::getParam('pagination.limit', 50));
58
-        $page = (integer)(array_key_exists(Api::API_PAGE_FIELD, $criteria) ? $criteria[Api::API_PAGE_FIELD] : 1);
57
+        $nosqlOptions["limit"] = (integer) (array_key_exists(Api::API_LIMIT_FIELD, $criteria) ? $criteria[Api::API_LIMIT_FIELD] : Config::getParam('pagination.limit', 50));
58
+        $page = (integer) (array_key_exists(Api::API_PAGE_FIELD, $criteria) ? $criteria[Api::API_PAGE_FIELD] : 1);
59 59
         $nosqlOptions["skip"] = ($page === 1) ? 0 : ($page - 1) * $nosqlOptions["limit"];
60 60
 
61 61
         if ((array_key_exists(Api::API_ORDER_FIELD, $criteria)) && (is_array($criteria[Api::API_ORDER_FIELD]))) {
62 62
             $nosqlOptions["sort"] = [];
63 63
             foreach ($criteria[Api::API_ORDER_FIELD] as $field => $direction) {
64
-                $nosqlOptions["sort"][$field] = (abs($direction) === 1)  ? $direction : 1;
64
+                $nosqlOptions["sort"][$field] = (abs($direction) === 1) ? $direction : 1;
65 65
             }
66 66
         }
67 67
 
68 68
         $results = $collection->find($filters, $nosqlOptions);
69 69
         /** @var  $result */
70 70
         $items = $results->toArray();
71
-        foreach($items as $item) {
71
+        foreach ($items as $item) {
72 72
             $model->feed($item->getArrayCopy(), true);
73 73
             $resultSet->items[] = $model->getDtoCopy(true);
74 74
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         // Check index collation
98 98
         $options = [];
99 99
         $indexes = $collection->listIndexes();
100
-        foreach($indexes as $index) {
100
+        foreach ($indexes as $index) {
101 101
             $indexInfo = $index->__debugInfo();
102 102
             if (empty(array_diff(array_keys($index["key"]), array_keys($filters)))) {
103 103
                 if (array_key_exists("collation", $indexInfo)) {
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         }
110 110
 
111 111
         if (array_key_exists("collation", $options)) {
112
-            foreach($filters as $key=>$filter) {
112
+            foreach ($filters as $key=>$filter) {
113 113
                 if (is_string($criteria[$key])) {
114 114
                     $filters[$key] = $criteria[$key];
115 115
                 }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     {
128 128
         $filterValue = $criteria[$property->name];
129 129
         if (is_array($filterValue)) {
130
-            if(in_array($filterValue[0], [
130
+            if (in_array($filterValue[0], [
131 131
                 self::NOSQL_NOT_NULL_OPERATOR,
132 132
                 self::NOSQL_IN_OPERATOR,
133 133
             ])) {
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                     self::NOSQL_IN_OPERATOR => $filterValue,
143 143
                 ];
144 144
             }
145
-        } elseif(in_array($filterValue, [
145
+        } elseif (in_array($filterValue, [
146 146
             self::NOSQL_NOT_NULL_OPERATOR,
147 147
         ])) {
148 148
             $filterValue = [
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
                         break;
167 167
                 }
168 168
             } elseif (NOSQLBase::NOSQL_TYPE_INTEGER === $property->type) {
169
-                $filterValue = (integer)$filterValue;
169
+                $filterValue = (integer) $filterValue;
170 170
             } else {
171
-                $filterValue = (float)$filterValue;
171
+                $filterValue = (float) $filterValue;
172 172
             }
173 173
             $filterValue = [
174 174
                 '$eq' => $filterValue,
Please login to merge, or discard this patch.