Passed
Push — master ( 9e6bb9...31d782 )
by Fran
03:01 queued 47s
created
src/NOSQL/Services/ParserService.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         $dns .= '@' . Config::getParam('nosql.host', 'localhost', $lowerDomain);
28 28
 
29 29
         $database = Config::getParam('nosql.database', 'nosql', $lowerDomain);
30
-        if(null !== Config::getParam('nosql.replicaset')) {
30
+        if (null !== Config::getParam('nosql.replicaset')) {
31 31
             $dns .= '/' . $database . '?ssl=true&replicaSet=' . Config::getParam('nosql.replicaset', null, $lowerDomain);
32 32
             $dns .= '&authSource=admin&serverSelectionTryOnce=false&serverSelectionTimeoutMS=15000&retryWrites=true';
33 33
         } else {
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function checkAndSave($domain, $collection, NOSQLModelDto $dto) {
50 50
         $errors = $dto->validate();
51
-        if(empty($errors)) {
51
+        if (empty($errors)) {
52 52
 
53 53
         } else {
54 54
             throw new ApiException(t('Dto not valid'), 400);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     public function hydrateModelFromRequest(array $data, $className) {
65 65
         $model = null;
66 66
         $reflectionClass = new \ReflectionClass($className);
67
-        if($reflectionClass->isSubclassOf(NOSQLBase::class)) {
67
+        if ($reflectionClass->isSubclassOf(NOSQLBase::class)) {
68 68
             /** @var NOSQLActiveRecord $modelName */
69 69
             $modelName = $className::MODEL_CLASS;
70 70
             $model = $modelName::fromArray($data);
Please login to merge, or discard this patch.
src/NOSQL/Services/NOSQLService.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
      */
56 56
     private function extractTypes() {
57 57
         $baseClass = new \ReflectionClass(NOSQLBase::class);
58
-        if(null !== $baseClass) {
58
+        if (null !== $baseClass) {
59 59
             $types = [];
60
-            foreach($baseClass->getConstants() as $constant) {
60
+            foreach ($baseClass->getConstants() as $constant) {
61 61
                 $types[] = $constant;
62 62
             }
63 63
             $this->setTypes($types);
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
     public function getDomains() {
80 80
         $domains = [];
81 81
         $storedDomains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, TRUE);
82
-        if(!empty($storedDomains)) {
83
-            foreach($storedDomains as $domain => $data) {
82
+        if (!empty($storedDomains)) {
83
+            foreach ($storedDomains as $domain => $data) {
84 84
                 $domainLabel = str_replace(['@', '/'], '', $domain);
85
-                if('ROOT' !== $domainLabel) {
85
+                if ('ROOT' !== $domainLabel) {
86 86
                     $domains[] = $domainLabel;
87 87
                 }
88 88
             }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     public function getCollections($module) {
98 98
         $collections = [];
99 99
         $schemaFilename = CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'schema.json';
100
-        if(file_exists($schemaFilename)) {
100
+        if (file_exists($schemaFilename)) {
101 101
             $collections = $this->cache->getDataFromFile($schemaFilename, Cache::JSON, TRUE);
102 102
         }
103 103
         return $collections;
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
             '@NOSQL/generator/api.base.php.twig' => CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'Api' . DIRECTORY_SEPARATOR . 'base',
121 121
             '@NOSQL/generator/dto.php.twig' => CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'Dto' . DIRECTORY_SEPARATOR . 'Models',
122 122
         ];
123
-        foreach($collections as $raw) {
123
+        foreach ($collections as $raw) {
124 124
             $collection = new CollectionDto(false);
125 125
             $collection->fromArray($raw);
126
-            foreach($files as $template => $path) {
126
+            foreach ($files as $template => $path) {
127 127
                 GeneratorHelper::createDir($path);
128 128
                 $templateDump = $tpl->dump($template, [
129 129
                     'domain' => $module,
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                     'properties' => $collection->properties,
132 132
                 ]);
133 133
                 $force = false;
134
-                if(false !== strpos($template, 'dto') || false !== strpos($template, 'base')) {
134
+                if (false !== strpos($template, 'dto') || false !== strpos($template, 'base')) {
135 135
                     $force = true;
136 136
                 }
137 137
                 $this->writeTemplateToFile($templateDump, $path . DIRECTORY_SEPARATOR . $collection->name . '.php', $force);
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         $db = ParserService::getInstance()->createConnection($module);
171 171
         $collections = $this->getCollections($module);
172 172
         $success = true;
173
-        foreach($collections as $raw) {
173
+        foreach ($collections as $raw) {
174 174
             $jsonSchema = $this->parseCollection($raw);
175 175
             try {
176 176
                 /** @var BSONDocument $result */
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
                 ]);
182 182
                 $response = $result->getArrayCopy();
183 183
                 $success = array_key_exists('ok', $response) && $response['ok'] > 0;
184
-            } catch(\Exception $exception) {
185
-                if($exception->getCode() !== 48) {
184
+            } catch (\Exception $exception) {
185
+                if ($exception->getCode() !== 48) {
186 186
                     $success = false;
187 187
                 }
188 188
             }
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
                     $property = new StringPropertyDto(false);
214 214
                     break;
215 215
             }
216
-            if(array_key_exists('type', $rawProperty)) {
216
+            if (array_key_exists('type', $rawProperty)) {
217 217
                 $property->bsonType = $rawProperty['type'];
218 218
             }
219
-            if(array_key_exists('description', $rawProperty)) {
219
+            if (array_key_exists('description', $rawProperty)) {
220 220
                 $property->description = $rawProperty['description'];
221 221
             }
222 222
             if (array_key_exists('required', $rawProperty) && $rawProperty['required']) {
Please login to merge, or discard this patch.