Completed
Push — master ( 820d48...a25531 )
by Fran
04:13
created
src/NOSQL/Models/base/NOSQLParserTrait.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -73,18 +73,18 @@
 block discarded – undo
73 73
      * @throws \PSFS\base\exception\GeneratorException
74 74
      */
75 75
     protected function hydrate() {
76
-        if(empty($this->domain)) {
76
+        if (empty($this->domain)) {
77 77
             throw new NOSQLParserException(t('Domain not defined'), NOSQLParserException::NOSQL_PARSER_DOMAIN_NOT_DEFINED);
78 78
         }
79 79
         $paths = GeneratorHelper::getDomainPaths($this->domain);
80 80
         $schemaFilename = $paths['base'] . 'Config' . DIRECTORY_SEPARATOR . 'schema.json';
81
-        if(file_exists($schemaFilename)) {
81
+        if (file_exists($schemaFilename)) {
82 82
             $schema = Cache::getInstance()->getDataFromFile($schemaFilename, Cache::JSON, true);
83 83
             $class = get_called_class();
84 84
             $this->schema = new CollectionDto(false);
85
-            foreach($schema as $collection) {
85
+            foreach ($schema as $collection) {
86 86
                 $collectionName = $collection['name'];
87
-                if(false !== strpos($class, $collectionName)) {
87
+                if (false !== strpos($class, $collectionName)) {
88 88
                     $this->schema->fromArray($collection);
89 89
                     break;
90 90
                 }
Please login to merge, or discard this patch.
src/NOSQL/Models/NOSQLQuery.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         $con = NOSQLParserTrait::initConnection($model, $con);
27 27
         $collection = $con->selectCollection($model->getSchema()->name);
28 28
         $result = $collection->findOne(['_id' => new ObjectId($pk)]);
29
-        if(null !== $result) {
29
+        if (null !== $result) {
30 30
             $model->feed($result->getArrayCopy());
31 31
         } else {
32 32
             throw new ApiException(t('Document not found'), 404);
@@ -53,21 +53,21 @@  discard block
 block discarded – undo
53 53
 
54 54
         $resultSet->count = $collection->countDocuments($filters, $nosqlOptions);
55 55
 
56
-        $nosqlOptions["limit"] = (integer)(array_key_exists(Api::API_LIMIT_FIELD, $criteria) ? $criteria[Api::API_LIMIT_FIELD] : Config::getParam('pagination.limit', 50));
57
-        $page = (integer)(array_key_exists(Api::API_PAGE_FIELD, $criteria) ? $criteria[Api::API_PAGE_FIELD] : 1);
56
+        $nosqlOptions["limit"] = (integer) (array_key_exists(Api::API_LIMIT_FIELD, $criteria) ? $criteria[Api::API_LIMIT_FIELD] : Config::getParam('pagination.limit', 50));
57
+        $page = (integer) (array_key_exists(Api::API_PAGE_FIELD, $criteria) ? $criteria[Api::API_PAGE_FIELD] : 1);
58 58
         $nosqlOptions["skip"] = ($page === 1) ? 0 : ($page - 1) * $nosqlOptions["limit"];
59 59
 
60 60
         if ((array_key_exists(Api::API_ORDER_FIELD, $criteria)) && (is_array($criteria[Api::API_ORDER_FIELD]))) {
61 61
             $nosqlOptions["sort"] = [];
62 62
             foreach ($criteria[Api::API_ORDER_FIELD] as $field => $direction) {
63
-                $nosqlOptions["sort"][$field] = (abs($direction) === 1)  ? $direction : 1;
63
+                $nosqlOptions["sort"][$field] = (abs($direction) === 1) ? $direction : 1;
64 64
             }
65 65
         }
66 66
 
67 67
         $results = $collection->find($filters, $nosqlOptions);
68 68
         /** @var  $result */
69 69
         $items = $results->toArray();
70
-        foreach($items as $item) {
70
+        foreach ($items as $item) {
71 71
             $model->feed($item->getArrayCopy(), true);
72 72
             $resultSet->items[] = $model->getDtoCopy(true);
73 73
         }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         // Check index collation
97 97
         $options = [];
98 98
         $indexes = $collection->listIndexes();
99
-        foreach($indexes as $index) {
99
+        foreach ($indexes as $index) {
100 100
             $indexInfo = $index->__debugInfo();
101 101
             if (empty(array_diff(array_keys($index["key"]), array_keys($filters)))) {
102 102
                 if (array_key_exists("collation", $indexInfo)) {
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         }
109 109
 
110 110
         if (array_key_exists("collation", $options)) {
111
-            foreach($filters as $key=>$filter) {
111
+            foreach ($filters as $key=>$filter) {
112 112
                 if (is_string($criteria[$key])) {
113 113
                     $filters[$key] = $criteria[$key];
114 114
                 }
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
                         break;
148 148
                 }
149 149
             } elseif (NOSQLBase::NOSQL_TYPE_INTEGER === $property->type) {
150
-                $filterValue = (integer)$filterValue;
150
+                $filterValue = (integer) $filterValue;
151 151
             } else {
152
-                $filterValue = (float)$filterValue;
152
+                $filterValue = (float) $filterValue;
153 153
             }
154 154
             $filterValue = [
155 155
                 '$eq' => $filterValue,
Please login to merge, or discard this patch.