Completed
Push — master ( 97cd4f...d81125 )
by
unknown
02:06
created
src/NOSQL/autoload.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,25 +5,25 @@  discard block
 block discarded – undo
5 5
  * @version 1.0
6 6
  * Autogenerated autoloader [2019-01-03 15:23:58]
7 7
  */
8
-if(!defined("BASE_DIR"))
9
-define("BASE_DIR", dirname( dirname(__DIR__) ) );
8
+if (!defined("BASE_DIR"))
9
+define("BASE_DIR", dirname(dirname(__DIR__)));
10 10
 
11 11
 require_once __DIR__ . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'config.php';
12 12
 
13
-if(!function_exists("NOSQL_Autoloader")) {
13
+if (!function_exists("NOSQL_Autoloader")) {
14 14
     // autoloader
15
-    function NOSQL_Autoloader( $class ) {
15
+    function NOSQL_Autoloader($class) {
16 16
         // it only autoload class into the Rain scope
17 17
         if (false !== preg_match('/^\\\?NOSQL/', $class)) {
18 18
             // Change order src
19 19
             $class = preg_replace('/^\\\?NOSQL/', 'NOSQL', $class);
20 20
             // transform the namespace in path
21
-            $path = str_replace("\\", DIRECTORY_SEPARATOR, $class );
21
+            $path = str_replace("\\", DIRECTORY_SEPARATOR, $class);
22 22
             // filepath
23 23
             $abs_path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $path . ".php";
24 24
 
25 25
             // require the file
26
-            if(file_exists($abs_path)) {
26
+            if (file_exists($abs_path)) {
27 27
                 require_once $abs_path;
28 28
             }
29 29
         }
@@ -31,5 +31,5 @@  discard block
 block discarded – undo
31 31
     }
32 32
 
33 33
     // register the autoloader
34
-    spl_autoload_register( "NOSQL_Autoloader" );
34
+    spl_autoload_register("NOSQL_Autoloader");
35 35
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,9 @@
 block discarded – undo
5 5
  * @version 1.0
6 6
  * Autogenerated autoloader [2019-01-03 15:23:58]
7 7
  */
8
-if(!defined("BASE_DIR"))
9
-define("BASE_DIR", dirname( dirname(__DIR__) ) );
8
+if(!defined("BASE_DIR")) {
9
+    define("BASE_DIR", dirname( dirname(__DIR__) ) );
10
+}
10 11
 
11 12
 require_once __DIR__ . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'config.php';
12 13
 
Please login to merge, or discard this patch.
src/NOSQL/Api/NOSQL.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         $code = 200;
58 58
         try {
59 59
             $this->srv->setCollections($module, $this->getRequest()->getRawData());
60
-        } catch(\Exception $exception) {
60
+        } catch (\Exception $exception) {
61 61
             $success = false;
62 62
             $code = 400;
63 63
             Logger::log($exception->getMessage(), LOG_WARNING);
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         $code = 200;
76 76
         try {
77 77
             $success = $this->srv->syncCollections($module);
78
-        } catch(\Exception $exception) {
78
+        } catch (\Exception $exception) {
79 79
             $success = false;
80 80
             $code = 400;
81 81
             Logger::log($exception->getMessage(), LOG_WARNING);
Please login to merge, or discard this patch.
src/NOSQL/Controller/base/NOSQLBaseController.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
     const DOMAIN = 'NOSQL';
15 15
 
16 16
     /**
17
-    * @Autoload
18
-    * @var \NOSQL\Services\NOSQLService
19
-    */
17
+     * @Autoload
18
+     * @var \NOSQL\Services\NOSQLService
19
+     */
20 20
     protected $srv;
21 21
 
22 22
     /**
23
-    * Constructor por defecto
24
-    */
23
+     * Constructor por defecto
24
+     */
25 25
     function __construct() {
26 26
         $this->init();
27 27
         $this->setDomain('NOSQL')
Please login to merge, or discard this patch.
src/NOSQL/Controller/NOSQLController.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
 class NOSQLController extends NOSQLBaseController {
15 15
 
16 16
     /**
17
-    * Index
18
-    * @GET
19
-    * @label  Admin nosql composer
20
-    * @action true
21
-    * @visible true
22
-    * @route /admin/nosql
23
-    * @return string HTML
24
-    */
17
+     * Index
18
+     * @GET
19
+     * @label  Admin nosql composer
20
+     * @action true
21
+     * @visible true
22
+     * @route /admin/nosql
23
+     * @return string HTML
24
+     */
25 25
     public function index() {
26 26
         return $this->render('index.html.twig');
27 27
     }
Please login to merge, or discard this patch.
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/Helpers/NOSQLApiHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     public static function parseForm(CollectionDto $collectionDto) {
34 34
         $form = new Form(false);
35 35
         $form->addField(self::generateId());
36
-        foreach($collectionDto->properties as $property) {
36
+        foreach ($collectionDto->properties as $property) {
37 37
             $values = null;
38 38
             $data = [];
39 39
             $url = null;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
                 case NOSQLBase::NOSQL_TYPE_ENUM:
59 59
                     $type = Field::COMBO_TYPE;
60 60
                     $enumValues = explode('|', $property->enum);
61
-                    foreach($enumValues as $value) {
61
+                    foreach ($enumValues as $value) {
62 62
                         $data[] = [
63 63
                             $property->name => $value,
64 64
                             'Label' => t($value),
Please login to merge, or discard this patch.
src/NOSQL/Models/base/NOSQLStatusTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      * @param string $property
80 80
      */
81 81
     public function addChanges($property) {
82
-        if(!in_array($property, $this->changes)) {
82
+        if (!in_array($property, $this->changes)) {
83 83
             $this->changes[] = $property;
84 84
         }
85 85
     }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      * @throws \NOSQL\Exceptions\NOSQLValidationException
112 112
      */
113 113
     public static function invokeHook(NOSQLActiveRecord $model, NOSQLModelDto $dto, $hook, Database $con = null) {
114
-        if(method_exists($model, $hook)) {
114
+        if (method_exists($model, $hook)) {
115 115
             $con = self::initConnection($model, $con);
116 116
             $model->feed($dto->toArray());
117 117
             $model->$hook($con);
Please login to merge, or discard this patch.
src/NOSQL/Api/base/NOSQLBase.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
     public function getApi()
57 57
     {
58 58
         $class = explode('\\', get_called_class());
59
-        return $class[count($class)-1];
59
+        return $class[count($class) - 1];
60 60
     }
61 61
 
62 62
     /**
Please login to merge, or discard this patch.
src/NOSQL/Services/NOSQLService.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
      */
58 58
     private function extractTypes() {
59 59
         $baseClass = new \ReflectionClass(NOSQLBase::class);
60
-        if(null !== $baseClass) {
60
+        if (null !== $baseClass) {
61 61
             $types = [];
62
-            foreach($baseClass->getConstants() as $constant) {
62
+            foreach ($baseClass->getConstants() as $constant) {
63 63
                 $types[] = $constant;
64 64
             }
65 65
             $this->setTypes($types);
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
     public function getDomains() {
82 82
         $domains = [];
83 83
         $storedDomains = $this->cache->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json', Cache::JSON, TRUE);
84
-        if(!empty($storedDomains)) {
85
-            foreach($storedDomains as $domain => $data) {
84
+        if (!empty($storedDomains)) {
85
+            foreach ($storedDomains as $domain => $data) {
86 86
                 $domainLabel = str_replace(['@', '/'], '', $domain);
87
-                if('ROOT' !== $domainLabel) {
87
+                if ('ROOT' !== $domainLabel) {
88 88
                     $domains[] = $domainLabel;
89 89
                 }
90 90
             }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     public function getCollections($module) {
100 100
         $collections = [];
101 101
         $schemaFilename = CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'schema.json';
102
-        if(file_exists($schemaFilename)) {
102
+        if (file_exists($schemaFilename)) {
103 103
             $collections = $this->cache->getDataFromFile($schemaFilename, Cache::JSON, TRUE);
104 104
         }
105 105
         return $collections;
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
             '@NOSQL/generator/api.base.php.twig' => CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'Api' . DIRECTORY_SEPARATOR . 'Base',
123 123
             '@NOSQL/generator/dto.php.twig' => CORE_DIR . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'Dto' . DIRECTORY_SEPARATOR . 'Models',
124 124
         ];
125
-        foreach($collections as $raw) {
125
+        foreach ($collections as $raw) {
126 126
             $collection = new CollectionDto(false);
127 127
             $collection->fromArray($raw);
128
-            foreach($files as $template => $path) {
128
+            foreach ($files as $template => $path) {
129 129
                 GeneratorHelper::createDir($path);
130 130
                 $templateDump = $tpl->dump($template, [
131 131
                     'domain' => $module,
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                     'properties' => $collection->properties,
134 134
                 ]);
135 135
                 $force = false;
136
-                if(false !== strpos($template, 'dto') || false !== strpos(strtolower($template), 'base')) {
136
+                if (false !== strpos($template, 'dto') || false !== strpos(strtolower($template), 'base')) {
137 137
                     $force = true;
138 138
                 }
139 139
                 $this->writeTemplateToFile($templateDump, $path . DIRECTORY_SEPARATOR . $collection->name . '.php', $force);
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
         try {
172 172
             $collection = $db->selectCollection($collectionDto['name']);
173 173
             $textIndexes = [];
174
-            foreach($collectionDto['properties'] as $property) {
175
-                if(in_array($property['type'], [NOSQLBase::NOSQL_TYPE_STRING, NOSQLBase::NOSQL_TYPE_OBJECT])) {
174
+            foreach ($collectionDto['properties'] as $property) {
175
+                if (in_array($property['type'], [NOSQLBase::NOSQL_TYPE_STRING, NOSQLBase::NOSQL_TYPE_OBJECT])) {
176 176
                     $textIndexes[$property['name']] = 'text';
177 177
                 }
178 178
             }
179
-            if(count($textIndexes)) {
179
+            if (count($textIndexes)) {
180 180
                 $collection->createIndex($textIndexes, ['name' => 'idx_text_' . $collectionDto['name']]);
181 181
             }
182 182
         } catch (\Exception $exception) {
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         $db = ParserService::getInstance()->createConnection($module);
194 194
         $collections = $this->getCollections($module);
195 195
         $success = true;
196
-        foreach($collections as $raw) {
196
+        foreach ($collections as $raw) {
197 197
             $jsonSchema = $this->parseCollection($raw);
198 198
             try {
199 199
                 /** @var BSONDocument $result */
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
                 ]);
205 205
                 $response = $result->getArrayCopy();
206 206
                 $success = array_key_exists('ok', $response) && $response['ok'] > 0;
207
-            } catch(\Exception $exception) {
208
-                if($exception->getCode() !== 48) {
207
+            } catch (\Exception $exception) {
208
+                if ($exception->getCode() !== 48) {
209 209
                     $success = false;
210 210
                 }
211 211
             }
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
                     $property = new StringPropertyDto(false);
238 238
                     break;
239 239
             }
240
-            if(array_key_exists('type', $rawProperty)) {
240
+            if (array_key_exists('type', $rawProperty)) {
241 241
                 $property->bsonType = $rawProperty['type'];
242 242
             }
243
-            if(array_key_exists('description', $rawProperty)) {
243
+            if (array_key_exists('description', $rawProperty)) {
244 244
                 $property->description = $rawProperty['description'];
245 245
             }
246 246
             if (array_key_exists('required', $rawProperty) && $rawProperty['required']) {
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     public function getValidations() {
259 259
         $fieldTypes = new \ReflectionClass(Field::class);
260 260
         $validations = [];
261
-        foreach($fieldTypes->getConstants() as $validation) {
261
+        foreach ($fieldTypes->getConstants() as $validation) {
262 262
             $validations[] = $validation;
263 263
         }
264 264
         return $validations;
Please login to merge, or discard this patch.