Passed
Push — master ( 76ec75...d0de83 )
by Fran
03:15
created
src/bootstrap.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,26 +4,26 @@  discard block
 block discarded – undo
4 4
 defined('PSFS_START_MEM') or define('PSFS_START_MEM', memory_get_usage());
5 5
 defined('PSFS_START_TS') or define('PSFS_START_TS', microtime(true));
6 6
 
7
-if(defined('PSFS_PHAR_DIR') && file_exists(PSFS_PHAR_DIR . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'environment.php')) {
8
-    @require_once PSFS_PHAR_DIR . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'environment.php';
7
+if (defined('PSFS_PHAR_DIR') && file_exists(PSFS_PHAR_DIR.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'environment.php')) {
8
+    @require_once PSFS_PHAR_DIR.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'environment.php';
9 9
 }
10 10
 
11 11
 defined('SOURCE_DIR') or define('SOURCE_DIR', __DIR__);
12 12
 if (preg_match('/vendor/', SOURCE_DIR)) {
13
-    defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
14
-    defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
15
-} else {
16
-    defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
17
-    defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
13
+    defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..');
14
+    defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'src');
15
+}else {
16
+    defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR.DIRECTORY_SEPARATOR.'..');
17
+    defined('CORE_DIR') or define('CORE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'modules');
18 18
 }
19
-defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor');
20
-defined('LOG_DIR') or define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
21
-defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
22
-defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
23
-defined('WEB_DIR') or define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
24
-defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
19
+defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'vendor');
20
+defined('LOG_DIR') or define('LOG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'logs');
21
+defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'cache');
22
+defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'config');
23
+defined('WEB_DIR') or define('WEB_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'html');
24
+defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR.DIRECTORY_SEPARATOR.'locale');
25 25
 
26
-if(!class_exists(bootstrap::class)) {
26
+if (!class_exists(bootstrap::class)) {
27 27
     /**
28 28
      * Class Bootstrap
29 29
      * @package PSFS
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
     class bootstrap {
32 32
         protected static $loaded = false;
33 33
         public static function load() {
34
-            if(!self::$loaded) {
34
+            if (!self::$loaded) {
35 35
                 defined('PSFS_BOOTSTRAP_LOADED') or define('PSFS_BOOTSTRAP_LOADED', true);
36
-                if(class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO);
36
+                if (class_exists("\\PSFS\\base\\Logger")) \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO);
37 37
                 self::$loaded = true;
38 38
             }
39 39
         }
Please login to merge, or discard this patch.
src/base/types/helpers/RouterHelper.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
     {
21 21
         Inspector::stats('[RouterHelper] Getting class to call for executing the request action');
22 22
         Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action);
23
-        $actionClass = class_exists($action['class']) ? $action['class'] : "\\" . $action['class'];
23
+        $actionClass = class_exists($action['class']) ? $action['class'] : "\\".$action['class'];
24 24
         $reflectionClass = new \ReflectionClass($actionClass);
25
-        if($reflectionClass->hasMethod('getInstance')) {
25
+        if ($reflectionClass->hasMethod('getInstance')) {
26 26
             $class = $reflectionClass->getMethod('getInstance')->invoke(null, $action['method']);
27
-        } else {
27
+        }else {
28 28
             $class = new $actionClass;
29 29
         }
30 30
         return $class;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $expr = preg_quote($expr, '/');
114 114
         $expr = str_replace('###', '(.*)', $expr);
115 115
         $expr2 = preg_replace('/\(\.\*\)$/', '', $expr);
116
-        $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path);
116
+        $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path);
117 117
         return $matched;
118 118
     }
119 119
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public static function extractDomainInfo(\ReflectionClass $class, $domain)
126 126
     {
127
-        $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
127
+        $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
128 128
         $templatesPath = 'templates';
129 129
         $publicPath = 'public';
130 130
         $modelsPath = 'models';
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
             $modelsPath = ucfirst($modelsPath);
135 135
         }
136 136
         if ($class->hasConstant('TPL')) {
137
-            $templatesPath .= DIRECTORY_SEPARATOR . $class->getConstant('TPL');
137
+            $templatesPath .= DIRECTORY_SEPARATOR.$class->getConstant('TPL');
138 138
         }
139 139
         return [
140 140
             'base' => $path,
141
-            'template' => $path . $templatesPath,
142
-            'model' => $path . $modelsPath,
143
-            'public' => $path . $publicPath,
141
+            'template' => $path.$templatesPath,
142
+            'model' => $path.$modelsPath,
143
+            'public' => $path.$publicPath,
144 144
         ];
145 145
     }
146 146
 
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
             foreach ($parameters as $param) {
165 165
                 if ($param->isOptional() && !is_array($param->getDefaultValue())) {
166 166
                     $params[$param->getName()] = $param->getDefaultValue();
167
-                    $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex);
168
-                } elseif(!$param->isOptional()) {
167
+                    $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex);
168
+                } elseif (!$param->isOptional()) {
169 169
                     $requirements[] = $param->getName();
170 170
                 }
171 171
             }
172
-        } else {
172
+        }else {
173 173
             $default = $regex;
174 174
         }
175 175
 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
             $httpMethod = self::extractReflectionHttpMethod($docComments);
266 266
             $icon = self::extractDocIcon($docComments);
267 267
             $label = self::extractReflectionLabel(str_replace('{__API__}', $api, $docComments));
268
-            $route = $httpMethod . "#|#" . $regex;
268
+            $route = $httpMethod."#|#".$regex;
269 269
             $route = preg_replace('/(\\r|\\f|\\t|\\n)/', '', $route);
270 270
             $info = [
271 271
                 'method' => $method->getName(),
Please login to merge, or discard this patch.
src/base/types/helpers/GeneratorHelper.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
             $objects = scandir($dir);
24 24
             foreach ($objects as $object) {
25 25
                 if ($object != "." && $object != "..") {
26
-                    if (filetype($dir . "/" . $object) == "dir") {
27
-                        self::deleteDir($dir . "/" . $object);
28
-                    } else {
29
-                        unlink($dir . "/" . $object);
26
+                    if (filetype($dir."/".$object) == "dir") {
27
+                        self::deleteDir($dir."/".$object);
28
+                    }else {
29
+                        unlink($dir."/".$object);
30 30
                     }
31 31
                 }
32 32
             }
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
     {
43 43
         $rootDirs = array("css", "js", "media", "font");
44 44
         foreach ($rootDirs as $dir) {
45
-            if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) {
45
+            if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) {
46 46
                 try {
47
-                    self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir);
48
-                } catch (\Exception $e) {
47
+                    self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir);
48
+                }catch (\Exception $e) {
49 49
                     syslog(LOG_INFO, $e->getMessage());
50 50
                 }
51 51
             }
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
     {
62 62
         try {
63 63
             if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) {
64
-                throw new \Exception(t('Can\'t create directory ') . $dir);
64
+                throw new \Exception(t('Can\'t create directory ').$dir);
65 65
             }
66
-        } catch (\Exception $e) {
66
+        }catch (\Exception $e) {
67 67
             syslog(LOG_WARNING, $e->getMessage());
68 68
             if (!file_exists(dirname($dir))) {
69
-                throw new GeneratorException($e->getMessage() . $dir);
69
+                throw new GeneratorException($e->getMessage().$dir);
70 70
             }
71 71
         }
72 72
     }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public static function getTemplatePath()
79 79
     {
80
-        $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
80
+        $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR;
81 81
         return realpath($path);
82 82
     }
83 83
 
@@ -96,15 +96,15 @@  discard block
 block discarded – undo
96 96
      * @throws \ReflectionException
97 97
      */
98 98
     public static function checkCustomNamespaceApi($namespace) {
99
-        if(!empty($namespace)) {
100
-            if(class_exists($namespace)) {
99
+        if (!empty($namespace)) {
100
+            if (class_exists($namespace)) {
101 101
                 $reflector = new \ReflectionClass($namespace);
102
-                if(!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) {
102
+                if (!$reflector->isSubclassOf(\PSFS\base\types\Api::class)) {
103 103
                     throw new GeneratorException(t('La clase definida debe extender de PSFS\\\base\\\types\\\Api'), 501);
104
-                } elseif(!$reflector->isAbstract()) {
104
+                } elseif (!$reflector->isAbstract()) {
105 105
                     throw new GeneratorException(t('La clase definida debe ser abstracta'), 501);
106 106
                 }
107
-            } else {
107
+            }else {
108 108
                 throw new GeneratorException(t('La clase definida para extender la API no existe'), 501);
109 109
             }
110 110
         }
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
      * @return array
116 116
      */
117 117
     public static function getDomainPaths($domain) {
118
-        $domains = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'domains.json'), true);
118
+        $domains = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'domains.json'), true);
119 119
         $paths = [];
120
-        if(null !== $domains) {
120
+        if (null !== $domains) {
121 121
             $keyDomains = array_keys($domains);
122
-            foreach($keyDomains as $keyDomain) {
122
+            foreach ($keyDomains as $keyDomain) {
123 123
                 $key = strtoupper(str_replace(['@', '/'], '', $keyDomain));
124
-                if(strtoupper($domain) === $key) {
124
+                if (strtoupper($domain) === $key) {
125 125
                     $paths = $domains[$keyDomain];
126 126
                     break;
127 127
                 }
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public static function createRoot($path = WEB_DIR, OutputInterface $output = null) {
139 139
 
140
-        if(null === $output) {
140
+        if (null === $output) {
141 141
             $output = new ConsoleOutput();
142 142
         }
143 143
 
144 144
         GeneratorHelper::createDir($path);
145 145
         $paths = array("js", "css", "img", "media", "font");
146 146
         foreach ($paths as $htmlPath) {
147
-            GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath);
147
+            GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath);
148 148
         }
149 149
 
150 150
         // Generates the root needed files
@@ -157,18 +157,18 @@  discard block
 block discarded – undo
157 157
         ];
158 158
         $output->writeln('Start creating html files');
159 159
         foreach ($files as $templates => $filename) {
160
-            $text = Template::getInstance()->dump("generator/html/" . $templates . '.html.twig');
161
-            if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) {
162
-                $output->writeln('Can\t create the file ' . $filename);
163
-            } else {
164
-                $output->writeln($filename . ' created successfully');
160
+            $text = Template::getInstance()->dump("generator/html/".$templates.'.html.twig');
161
+            if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) {
162
+                $output->writeln('Can\t create the file '.$filename);
163
+            }else {
164
+                $output->writeln($filename.' created successfully');
165 165
             }
166 166
         }
167 167
 
168 168
         //Export base locale translations
169
-        if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) {
170
-            GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
171
-            GeneratorService::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
169
+        if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) {
170
+            GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale');
171
+            GeneratorService::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale');
172 172
         }
173 173
     }
174 174
 }
175 175
\ No newline at end of file
Please login to merge, or discard this patch.