Completed
Push — master ( d580f1...36f3e7 )
by Fran
06:21
created
src/command/CreateDocumentRoot.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
     use Symfony\Component\Console\Input\InputInterface;
7 7
     use Symfony\Component\Console\Output\OutputInterface;
8 8
 
9
-    if (!isset($console)) $console = new Application();
9
+    if (!isset($console)) {
10
+        $console = new Application();
11
+    }
10 12
     $console
11 13
         ->register('psfs:create:root')
12 14
         ->setDefinition(array(
@@ -15,13 +17,17 @@  discard block
 block discarded – undo
15 17
         ->setDescription('Comando de creación del Document Root del projecto')
16 18
         ->setCode(function(InputInterface $input, OutputInterface $output) {
17 19
             $path = $input->getArgument('path');
18
-            if (empty($path)) $path = BASE_DIR.DIRECTORY_SEPARATOR.'html';
20
+            if (empty($path)) {
21
+                $path = BASE_DIR.DIRECTORY_SEPARATOR.'html';
22
+            }
19 23
             \PSFS\base\config\Config::createDir($path);
20 24
             $paths = array("js", "css", "img", "media", "font");
21 25
             foreach ($paths as $htmlPath) {
22 26
                 \PSFS\base\config\Config::createDir($path.DIRECTORY_SEPARATOR.$htmlPath);
23 27
             }
24
-            if (!file_exists(SOURCE_DIR.DIRECTORY_SEPARATOR.'html.tar.gz')) throw new \PSFS\base\exception\ConfigException("No existe el fichero del DocumentRoot");
28
+            if (!file_exists(SOURCE_DIR.DIRECTORY_SEPARATOR.'html.tar.gz')) {
29
+                throw new \PSFS\base\exception\ConfigException("No existe el fichero del DocumentRoot");
30
+            }
25 31
             $tar = new \Archive_Tar(realpath(SOURCE_DIR.DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR."html.tar.gz", true);
26 32
             $tar->extract(realpath($path));
27 33
             $output->writeln("Document root generado en ".$path);
Please login to merge, or discard this patch.
src/command/CreateModule.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,12 +29,16 @@  discard block
 block discarded – undo
29 29
 
30 30
             public function infoLog($msg)
31 31
             {
32
-                if ($this->verbosity) $this->log->writeln($msg);
32
+                if ($this->verbosity) {
33
+                    $this->log->writeln($msg);
34
+                }
33 35
             }
34 36
         }
35 37
     }
36 38
 
37
-    if (!isset($console)) $console = new Application();
39
+    if (!isset($console)) {
40
+        $console = new Application();
41
+    }
38 42
     $console
39 43
         ->register('psfs:create:module')
40 44
         ->setDefinition(array(
@@ -58,7 +62,7 @@  discard block
 block discarded – undo
58 62
                 {
59 63
                     \PSFS\services\GeneratorService::getInstance()->createStructureModule($module, $log);
60 64
                 }
61
-            }catch (\Exception $e)
65
+            } catch (\Exception $e)
62 66
             {
63 67
                 $output->writeln($e->getMessage());
64 68
                 $output->writeln($e->getTraceAsString());
Please login to merge, or discard this patch.
src/command/PSFSConsole.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,14 +31,18 @@
 block discarded – undo
31 31
     //Hidratamos con los comandos de PSFS
32 32
     $commands = new Finder();
33 33
     $commands->in(__DIR__)->notName("PSFSConsole.php");
34
-    foreach ($commands as $com) include_once($com->getRealPath());
34
+    foreach ($commands as $com) {
35
+        include_once($com->getRealPath());
36
+    }
35 37
 
36 38
     //Hidratamos con los comandos de los módulos
37 39
     if (file_exists(CORE_DIR))
38 40
     {
39 41
         $commands = new Finder();
40 42
         $commands->in(CORE_DIR)->path("Command")->name("*.php");
41
-        foreach ($commands as $com) include_once($com->getRealPath());
43
+        foreach ($commands as $com) {
44
+            include_once($com->getRealPath());
45
+        }
42 46
     }
43 47
 
44 48
     $console->run();
Please login to merge, or discard this patch.
src/services/AdminServices.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
     use PSFS\controller\Admin;
7 7
     use Symfony\Component\Finder\Finder;
8 8
 
9
-    class AdminServices extends Service{
9
+    class AdminServices extends Service {
10 10
 
11 11
         /**
12 12
          * @Inyectable
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
          */
31 31
         public function setAdminHeaders()
32 32
         {
33
-            if("login" === $this->config->get("admin_login")) return Admin::getInstance()->adminLogin("admin-setup");
33
+            if ("login" === $this->config->get("admin_login")) return Admin::getInstance()->adminLogin("admin-setup");
34 34
             $platform = trim(Config::getInstance()->get("platform_name"));
35 35
             header('HTTP/1.1 401 Unauthorized');
36
-            header('WWW-Authenticate: Basic Realm="' . $platform. '"');
36
+            header('WWW-Authenticate: Basic Realm="'.$platform.'"');
37 37
             echo _("Zona restringida");
38 38
             exit();
39 39
         }
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
         public function getAdmins()
46 46
         {
47 47
             $admins = $this->security->getAdmins();
48
-            if(!empty($admins))
48
+            if (!empty($admins))
49 49
             {
50
-                if(!$this->security->checkAdmin())
50
+                if (!$this->security->checkAdmin())
51 51
                 {
52 52
                     $this->setAdminHeaders();
53 53
                 }
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
          */
63 63
         private function parseAdmins(&$admins)
64 64
         {
65
-            if(!empty($admins)) foreach($admins as &$admin)
65
+            if (!empty($admins)) foreach ($admins as &$admin)
66 66
             {
67
-                if(isset($admin["profile"]))
67
+                if (isset($admin["profile"]))
68 68
                 {
69 69
                     $admin["class"] = $admin["profile"] == sha1("admin") ? 'primary' : "warning";
70
-                }else{
70
+                }else {
71 71
                     $admin["class"] = "primary";
72 72
                 }
73 73
             }
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
             $files->files()->in(LOG_DIR)->name("*.log")->sortByModifiedTime();
88 88
             $logs = array();
89 89
             /** @var \SplFileInfo $file */
90
-            foreach($files as $file)
90
+            foreach ($files as $file)
91 91
             {
92
-                $size = $file->getSize() / 8 / 1024;
92
+                $size = $file->getSize()/8/1024;
93 93
                 $time = date("c", $file->getMTime());
94 94
                 $dateTime = new \DateTime($time);
95
-                if(!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array();
95
+                if (!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array();
96 96
                 $logs[$dateTime->format("Y")][$dateTime->format("m")][$time] = array(
97 97
                     "filename" => $file->getFilename(),
98 98
                     "size" => round($size, 3)
@@ -116,27 +116,27 @@  discard block
 block discarded – undo
116 116
             $files->files()->in(LOG_DIR)->name($selectedLog);
117 117
             $file = null;
118 118
             $log = array();
119
-            foreach($files as $match)
119
+            foreach ($files as $match)
120 120
             {
121 121
                 $file = $match;
122 122
                 break;
123 123
             }
124 124
             /** @var \SplFileInfo $file */
125
-            if(!empty($file))
125
+            if (!empty($file))
126 126
             {
127 127
                 $time = date("c", $file->getMTime());
128 128
                 $dateTime = new \DateTime($time);
129 129
                 $monthOpen = $dateTime->format("m");
130
-                $content = file($file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename());
130
+                $content = file($file->getPath().DIRECTORY_SEPARATOR.$file->getFilename());
131 131
                 krsort($content);
132 132
                 $detailLog = array();
133
-                foreach($content as &$line)
133
+                foreach ($content as &$line)
134 134
                 {
135 135
                     list($line, $detail) = $this->parseLogLine($line, $match);
136 136
                     $detailLog[] = array_merge(array(
137 137
                         "log" => $line,
138 138
                     ), $detail);
139
-                    if(count($detailLog) >= 1000) break;
139
+                    if (count($detailLog) >= 1000) break;
140 140
                 }
141 141
                 $log = $detailLog;
142 142
             }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
                 $type = (isset($match[1][0])) ? $match[1][0] : '';
167 167
                 $type = explode(".", $type);
168
-                $type = count($type)>1 ? $type[1] : $type[0];
168
+                $type = count($type) > 1 ? $type[1] : $type[0];
169 169
                 switch ($type) {
170 170
                     case 'INFO':
171 171
                         $detail["type"] = "success";
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
                         break;
182 182
                 }
183 183
 
184
-            } catch (\Exception $e) {
184
+            }catch (\Exception $e) {
185 185
                 $detail = array(
186 186
                     "type" => "danger",
187 187
                 );
Please login to merge, or discard this patch.
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,7 +30,9 @@  discard block
 block discarded – undo
30 30
          */
31 31
         public function setAdminHeaders()
32 32
         {
33
-            if("login" === $this->config->get("admin_login")) return Admin::getInstance()->adminLogin("admin-setup");
33
+            if("login" === $this->config->get("admin_login")) {
34
+                return Admin::getInstance()->adminLogin("admin-setup");
35
+            }
34 36
             $platform = trim(Config::getInstance()->get("platform_name"));
35 37
             header('HTTP/1.1 401 Unauthorized');
36 38
             header('WWW-Authenticate: Basic Realm="' . $platform. '"');
@@ -62,12 +64,14 @@  discard block
 block discarded – undo
62 64
          */
63 65
         private function parseAdmins(&$admins)
64 66
         {
65
-            if(!empty($admins)) foreach($admins as &$admin)
67
+            if(!empty($admins)) {
68
+                foreach($admins as &$admin)
66 69
             {
67 70
                 if(isset($admin["profile"]))
68 71
                 {
69 72
                     $admin["class"] = $admin["profile"] == sha1("admin") ? 'primary' : "warning";
70
-                }else{
73
+            }
74
+                } else{
71 75
                     $admin["class"] = "primary";
72 76
                 }
73 77
             }
@@ -92,7 +96,9 @@  discard block
 block discarded – undo
92 96
                 $size = $file->getSize() / 8 / 1024;
93 97
                 $time = date("c", $file->getMTime());
94 98
                 $dateTime = new \DateTime($time);
95
-                if(!isset($logs[$dateTime->format("Y")])) $logs[$dateTime->format("Y")] = array();
99
+                if(!isset($logs[$dateTime->format("Y")])) {
100
+                    $logs[$dateTime->format("Y")] = array();
101
+                }
96 102
                 $logs[$dateTime->format("Y")][$dateTime->format("m")][$time] = array(
97 103
                     "filename" => $file->getFilename(),
98 104
                     "size" => round($size, 3)
@@ -136,7 +142,9 @@  discard block
 block discarded – undo
136 142
                     $detailLog[] = array_merge(array(
137 143
                         "log" => $line,
138 144
                     ), $detail);
139
-                    if(count($detailLog) >= 1000) break;
145
+                    if(count($detailLog) >= 1000) {
146
+                        break;
147
+                    }
140 148
                 }
141 149
                 $log = $detailLog;
142 150
             }
@@ -160,7 +168,9 @@  discard block
 block discarded – undo
160 168
 
161 169
                     $detail = json_decode($match[0][0], TRUE);
162 170
                 }
163
-                if (empty($detail)) $detail = array();
171
+                if (empty($detail)) {
172
+                    $detail = array();
173
+                }
164 174
                 preg_match_all('/\>\ (.*):/i', $line, $match);
165 175
 
166 176
                 $type = (isset($match[1][0])) ? $match[1][0] : '';
Please login to merge, or discard this patch.
src/test/PSFSTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 use PSFS\base\Security;
9 9
 use PSFS\Dispatcher;
10 10
 
11
-class PSFSTest extends \PHPUnit_Framework_TestCase{
11
+class PSFSTest extends \PHPUnit_Framework_TestCase {
12 12
 
13 13
     /**
14 14
      * Test básico para el funcionamiento del Dispatcher
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         $this->assertTrue($router instanceof Router);
57 57
 
58 58
         // Revisamos que exista el fichero de rutas
59
-        $this->assertFileExists(CONFIG_DIR . DIRECTORY_SEPARATOR . "urls.json");
59
+        $this->assertFileExists(CONFIG_DIR.DIRECTORY_SEPARATOR."urls.json");
60 60
 
61 61
         // Revisamos que tengamos rutas de administración y como mínimo la de admin
62 62
         $adminRoutes = $router->getAdminRoutes();
Please login to merge, or discard this patch.
src/test/base/DIspatcherTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
         public function testWarning() {
101 101
             $this->getInstance($this->mockConfiguredDebugConfig());
102 102
             //This throws a warning because file 'test.txt' not exists
103
-            file_get_contents(__DIR__ . "test.txt");
103
+            file_get_contents(__DIR__."test.txt");
104 104
         }
105 105
 
106 106
         public function testNormalExecution() {
Please login to merge, or discard this patch.
src/base/dto/Form.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
         {
22 22
             $array = array();
23 23
             $array['fields'] = array();
24
-            foreach($this->fields as $field) {
24
+            foreach ($this->fields as $field) {
25 25
                 $array['fields'][] = $field->__toArray();
26 26
             }
27 27
             return $array;
Please login to merge, or discard this patch.
src/base/types/AuthApi.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@
 block discarded – undo
26 26
         {
27 27
             $namespace = explode('\\', $this->getModelTableMap());
28 28
             $module = strtolower($namespace[0]);
29
-            $secret = Config::getInstance()->get($module . '.api.secret');
29
+            $secret = Config::getInstance()->get($module.'.api.secret');
30 30
             if (NULL === $secret) {
31 31
                 $secret = Config::getInstance()->get("api.secret");
32 32
             }
33 33
             if (NULL === $secret) {
34 34
                 $auth = TRUE;
35
-            } else {
35
+            }else {
36 36
                 $token = Request::getInstance()->getHeader('X-API-SEC-TOKEN');
37 37
                 if (array_key_exists('API_TOKEN', $this->query)) {
38 38
                     $token = $this->query['API_TOKEN'];
Please login to merge, or discard this patch.