Completed
Push — master ( f100fd...4450c4 )
by
unknown
02:19
created
src/NOSQL/Models/base/NOSQLModelTrait.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     public function __get($name)
25 25
     {
26 26
         $value = null;
27
-        if(null !== $this->dto && property_exists($this->dto, $name)) {
27
+        if (null !== $this->dto && property_exists($this->dto, $name)) {
28 28
             $value = $this->dto->$name;
29 29
         }
30 30
         return $value;
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function __set($name, $value)
38 38
     {
39
-        if(null !== $this->dto && property_exists($this->dto, $name)) {
39
+        if (null !== $this->dto && property_exists($this->dto, $name)) {
40 40
             $this->dto->$name = $value;
41 41
             $this->addChanges($name);
42 42
         }
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function __call($name, $arguments)
47 47
     {
48
-        if(preg_match('/^(set|get)/', $name)) {
48
+        if (preg_match('/^(set|get)/', $name)) {
49 49
             $property = str_replace(['set', 'Set', 'get', 'Get'], '', $name);
50
-            if(false !== stripos($name, 'set')) {
50
+            if (false !== stripos($name, 'set')) {
51 51
                 $this->$property = $arguments[0];
52 52
             } else {
53 53
                 return $this->$property;
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
     public function feed(array $data, $withName = false) {
65 65
         $name = '';
66 66
         $sep = '';
67
-        foreach($data as $key => $value) {
68
-            if($value instanceof ObjectId) {
67
+        foreach ($data as $key => $value) {
68
+            if ($value instanceof ObjectId) {
69 69
                 $this->dto->setPk($value->jsonSerialize()['$oid']);
70 70
                 $name = $this->dto->getPk();
71
-            } elseif($key === '_last_update') {
71
+            } elseif ($key === '_last_update') {
72 72
                 $this->dto->setLastUpdate($value instanceof UTCDateTime ? $value : null);
73 73
             } else {
74 74
                 if (is_object($value)) {
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
                     }
80 80
                 }
81 81
                 $this->$key = $value;
82
-                if(in_array(strtolower($key), ['name', 'label', 'title', 'method'])) {
82
+                if (in_array(strtolower($key), ['name', 'label', 'title', 'method'])) {
83 83
                     $name .= $sep . $value;
84 84
                     $sep = ' ';
85 85
                 }
86 86
             }
87 87
         }
88
-        if($withName) {
88
+        if ($withName) {
89 89
             $this->dto->setName($name);
90 90
         }
91 91
     }
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
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         $con = NOSQLParserTrait::initConnection($model, $con);
26 26
         $collection = $con->selectCollection($model->getSchema()->name);
27 27
         $result = $collection->findOne(['_id' => new ObjectId($pk)]);
28
-        if(null !== $result) {
28
+        if (null !== $result) {
29 29
             $model->feed($result->getArrayCopy());
30 30
         } else {
31 31
             throw new ApiException(t('Document not found'), 404);
@@ -52,21 +52,21 @@  discard block
 block discarded – undo
52 52
 
53 53
         $resultSet->count = $collection->count($filters, $nosqlOptions);
54 54
 
55
-        $nosqlOptions["limit"] = (integer)(array_key_exists(Api::API_LIMIT_FIELD, $criteria) ? $criteria[Api::API_LIMIT_FIELD] : Config::getParam('pagination.limit', 50));
56
-        $page = (integer)(array_key_exists(Api::API_PAGE_FIELD, $criteria) ? $criteria[Api::API_PAGE_FIELD] : 1);
55
+        $nosqlOptions["limit"] = (integer) (array_key_exists(Api::API_LIMIT_FIELD, $criteria) ? $criteria[Api::API_LIMIT_FIELD] : Config::getParam('pagination.limit', 50));
56
+        $page = (integer) (array_key_exists(Api::API_PAGE_FIELD, $criteria) ? $criteria[Api::API_PAGE_FIELD] : 1);
57 57
         $nosqlOptions["skip"] = ($page === 1) ? 0 : ($page - 1) * $nosqlOptions["limit"];
58 58
 
59 59
         if ((array_key_exists(Api::API_ORDER_FIELD, $criteria)) && (is_array($criteria[Api::API_ORDER_FIELD]))) {
60 60
             $nosqlOptions["sort"] = [];
61 61
             foreach ($criteria[Api::API_ORDER_FIELD] as $field => $direction) {
62
-                $nosqlOptions["sort"][$field] = (abs($direction) === 1)  ? $direction : 1;
62
+                $nosqlOptions["sort"][$field] = (abs($direction) === 1) ? $direction : 1;
63 63
             }
64 64
         }
65 65
 
66 66
         $results = $collection->find($filters, $nosqlOptions);
67 67
         /** @var  $result */
68 68
         $items = $results->toArray();
69
-        foreach($items as $item) {
69
+        foreach ($items as $item) {
70 70
             $model->feed($item->getArrayCopy(), true);
71 71
             $resultSet->items[] = $model->getDtoCopy(true);
72 72
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         // Check index collation
92 92
         $options = [];
93 93
         $indexes = $collection->listIndexes();
94
-        foreach($indexes as $index) {
94
+        foreach ($indexes as $index) {
95 95
             $indexInfo = $index->__debugInfo();
96 96
             if (empty(array_diff(array_keys($index["key"]), array_keys($filters)))) {
97 97
                 if (array_key_exists("collation", $indexInfo)) {
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         }
104 104
 
105 105
         if (array_key_exists("collation", $options)) {
106
-            foreach($filters as $key=>$filter) {
106
+            foreach ($filters as $key=>$filter) {
107 107
                 if (is_string($criteria[$key])) {
108 108
                     $filters[$key] = $criteria[$key];
109 109
                 }
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
                         break;
143 143
                 }
144 144
             } elseif (NOSQLBase::NOSQL_TYPE_INTEGER === $property->type) {
145
-                $filterValue = (integer)$filterValue;
145
+                $filterValue = (integer) $filterValue;
146 146
             } else {
147
-                $filterValue = (float)$filterValue;
147
+                $filterValue = (float) $filterValue;
148 148
             }
149 149
             $filterValue = [
150 150
                 '$eq' => $filterValue,
Please login to merge, or discard this patch.