Test Failed
Push — master ( 9bd92d...e12c59 )
by Federico
04:41
created
dist/jate/modules/Parser/Parser.php 1 patch
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -28,20 +28,25 @@  discard block
 block discarded – undo
28 28
       return $parser;
29 29
     }
30 30
     public static function parseText( $_text, $_parameters = [], $_type = "html" ) {
31
-      if(!is_string($_text) || !is_string($_type))
32
-        throw new JException("Parameter must be a string.");
33
-      if(!is_array($_parameters))
34
-        throw new JException("Parameter must be an array.");
31
+      if(!is_string($_text) || !is_string($_type)) {
32
+              throw new JException("Parameter must be a string.");
33
+      }
34
+      if(!is_array($_parameters)) {
35
+              throw new JException("Parameter must be an array.");
36
+      }
35 37
       $parser = self::setParser($_type);
36
-      if($parser === -1)
37
-        return $_text;
38
+      if($parser === -1) {
39
+              return $_text;
40
+      }
38 41
       return $parser->drawText($_text, $_parameters);
39 42
     }
40 43
     public static function parseFileMan( $_path, $_parameters = [], $_type = "html"  ) {
41
-      if(!is_string($_path))
42
-        throw new JException("Parameter must be a string.");
43
-      if(!file_exists($_path))
44
-        throw new JException("File [$_path] not found.");
44
+      if(!is_string($_path)) {
45
+              throw new JException("Parameter must be a string.");
46
+      }
47
+      if(!file_exists($_path)) {
48
+              throw new JException("File [$_path] not found.");
49
+      }
45 50
       $string = file_get_contents($_path);
46 51
       try {
47 52
         $text = self::parseText($string, $_parameters, $_type);
@@ -51,8 +56,9 @@  discard block
 block discarded – undo
51 56
       return $text;
52 57
     }
53 58
     public static function parseFile( $_path, $_parameters = [] ) {
54
-      if(!is_string($_path))
55
-        throw new JException("Parameter must be a string.");
59
+      if(!is_string($_path)) {
60
+              throw new JException("Parameter must be a string.");
61
+      }
56 62
       $extension = explode(".", $_path);
57 63
       $extension = $extension[count($extension)-1];
58 64
       $extension = strtolower($extension);
Please login to merge, or discard this patch.
dist/jate/modules/JException/JException.php 1 patch
Braces   +17 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,24 +3,29 @@
 block discarded – undo
3 3
     static protected $escapeString = "|jate|";
4 4
     public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) {
5 5
       parent::__construct($_message, $_code, $_previous);
6
-      if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"]))
7
-        $this->file  = debug_backtrace()[$_level]["file"];
8
-      if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"]))
9
-        $this->line  = debug_backtrace()[$_level]["line"];
10
-      if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"]))
11
-        $this->function = debug_backtrace()[$_level]["function"];
12
-      if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"]))
13
-        $this->class = debug_backtrace()[$_level]["class"];
6
+      if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["file"])) {
7
+              $this->file  = debug_backtrace()[$_level]["file"];
8
+      }
9
+      if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["line"])) {
10
+              $this->line  = debug_backtrace()[$_level]["line"];
11
+      }
12
+      if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["function"])) {
13
+              $this->function = debug_backtrace()[$_level]["function"];
14
+      }
15
+      if(isset(debug_backtrace()[$_level]) && isset(debug_backtrace()[$_level]["class"])) {
16
+              $this->class = debug_backtrace()[$_level]["class"];
17
+      }
14 18
     }
15 19
     public function __toString() {
16 20
       return JException::encode(JException::decode($this->message));
17 21
     }
18 22
     static public function decode( $_message ) {
19 23
       $messageSplitted = explode(JException::$escapeString, $_message);
20
-      if(count($messageSplitted) == 3)
21
-        return $messageSplitted[1];
22
-      else
23
-        return $_message;
24
+      if(count($messageSplitted) == 3) {
25
+              return $messageSplitted[1];
26
+      } else {
27
+              return $_message;
28
+      }
24 29
     }
25 30
     static public function encode( $_message ) {
26 31
       $escape = JException::$escapeString;
Please login to merge, or discard this patch.
dist/jate/modules/File/File.php 1 patch
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,16 +24,20 @@  discard block
 block discarded – undo
24 24
       $this->files["required"][] = $_file;
25 25
     }
26 26
     public function addFiles( $_files ) {
27
-      if(!is_array($_files))
28
-        throw new JException("Parameter must be an array.");
29
-      foreach ($_files as $value)
30
-        $this->addFile($value);
27
+      if(!is_array($_files)) {
28
+              throw new JException("Parameter must be an array.");
29
+      }
30
+      foreach ($_files as $value) {
31
+              $this->addFile($value);
32
+      }
31 33
     }
32 34
     public function addFilesRequired( $_files ) {
33
-      if(!is_array($_files))
34
-        throw new JException("Parameter must be an array.");
35
-      foreach ($_files as $value)
36
-        $this->addFileRequired($value);
35
+      if(!is_array($_files)) {
36
+              throw new JException("Parameter must be an array.");
37
+      }
38
+      foreach ($_files as $value) {
39
+              $this->addFileRequired($value);
40
+      }
37 41
     }
38 42
     public function getFiles() {
39 43
       return $this->files["attached"];
@@ -42,10 +46,12 @@  discard block
 block discarded – undo
42 46
       return $this->files["required"];
43 47
     }
44 48
     protected function isCorrectPath( $_file ) {
45
-      if(!is_string($_file))
46
-        throw new JException("Path must be a string.");
47
-      if(!(file_exists($_file) || $this->isCorrectUrl($_file)))
48
-        throw new JException("File [$_file] not found.");
49
+      if(!is_string($_file)) {
50
+              throw new JException("Path must be a string.");
51
+      }
52
+      if(!(file_exists($_file) || $this->isCorrectUrl($_file))) {
53
+              throw new JException("File [$_file] not found.");
54
+      }
49 55
     }
50 56
     protected function isCorrectUrl( $_url ) {
51 57
       return strpos(@get_headers($_url)[0],'200') === false ? false : true;
Please login to merge, or discard this patch.
dist/jate/modules/Query/Query.php 1 patch
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,8 +10,9 @@  discard block
 block discarded – undo
10 10
       $this->currentConnection = null;
11 11
     }
12 12
     public function addConnection( $_path, $_name = "default" ) {
13
-      if(!is_string($_path))
14
-        throw new JException("Parameter must be a string.", 1);
13
+      if(!is_string($_path)) {
14
+              throw new JException("Parameter must be a string.", 1);
15
+      }
15 16
       try {
16 17
         $jConfig = new JConfig($_path);
17 18
         if($jConfig->enable) {
@@ -23,28 +24,33 @@  discard block
 block discarded – undo
23 24
       }
24 25
     }
25 26
     public function addConnectionMan( $_connection, $_name = "default") {
26
-      if(!is_object($_connection) || !is_a($_connection, "Connection"))
27
-        throw new JException("Parameter must be a Connection object.", 1);
27
+      if(!is_object($_connection) || !is_a($_connection, "Connection")) {
28
+              throw new JException("Parameter must be a Connection object.", 1);
29
+      }
28 30
       try {
29 31
         $this->connection["$_name"] = $_connection;
30 32
         $this->currentConnection = $_connection;
31
-        foreach ($this->modules as &$module)
32
-          if(isset($this->currentConnection))
33
+        foreach ($this->modules as &$module) {
34
+                  if(isset($this->currentConnection))
33 35
             $module->addConnectionMan($this->currentConnection, $_name);
36
+        }
34 37
       } catch (Exception $e) {
35 38
         throw new JException($e->getMessage(), 1);
36 39
       }
37 40
     }
38 41
     public function setConnection( $_name = "default" ) {
39
-      if(!is_string($_name))
40
-        throw new JException("Parameter must be a string.", 1);
41
-      if(!isset($this->connection["$_name"]))
42
-        throw new JException("This connection name does not exist.", 1);
42
+      if(!is_string($_name)) {
43
+              throw new JException("Parameter must be a string.", 1);
44
+      }
45
+      if(!isset($this->connection["$_name"])) {
46
+              throw new JException("This connection name does not exist.", 1);
47
+      }
43 48
       $this->currentConnection = $this->connection["$_name"];
44 49
     }
45 50
     public function query( $_query ) {
46
-      if(!is_string($_query))
47
-        throw new JException("Parameter must be a string.", 1);
51
+      if(!is_string($_query)) {
52
+              throw new JException("Parameter must be a string.", 1);
53
+      }
48 54
       try {
49 55
         $temp = $this->currentConnection->database->query($_query);
50 56
       } catch (Exception $e) {
@@ -53,8 +59,9 @@  discard block
 block discarded – undo
53 59
       return $temp;
54 60
     }
55 61
     public function queryInsert( $_query ) {
56
-      if(!is_string($_query))
57
-        throw new JException("Parameter must be a string.", 1);
62
+      if(!is_string($_query)) {
63
+              throw new JException("Parameter must be a string.", 1);
64
+      }
58 65
       try {
59 66
         $temp = $this->currentConnection->database->queryInsert($_query);
60 67
       } catch (Exception $e) {
@@ -63,8 +70,9 @@  discard block
 block discarded – undo
63 70
       return $temp;
64 71
     }
65 72
     public function queryFetch( $_query ) {
66
-      if(!is_string($_query))
67
-        throw new JException("Parameter must be a string.", 1);
73
+      if(!is_string($_query)) {
74
+              throw new JException("Parameter must be a string.", 1);
75
+      }
68 76
       try {
69 77
         $temp = $this->currentConnection->database->queryFetch($_query);
70 78
       } catch (Exception $e) {
@@ -73,8 +81,9 @@  discard block
 block discarded – undo
73 81
       return $temp;
74 82
     }
75 83
     public function queryArray( $_query ) {
76
-      if(!is_string($_query))
77
-        throw new JException("Parameter must be a string.", 1);
84
+      if(!is_string($_query)) {
85
+              throw new JException("Parameter must be a string.", 1);
86
+      }
78 87
       try {
79 88
         $temp = $this->currentConnection->database->queryArray($_query);
80 89
       } catch (Exception $e) {
Please login to merge, or discard this patch.
dist/jate/modules/Router/Router.php 1 patch
Braces   +20 added lines, -14 removed lines patch added patch discarded remove patch
@@ -6,8 +6,9 @@  discard block
 block discarded – undo
6 6
     protected $defaultPage;
7 7
     protected $urlCaseSensitive;
8 8
     public function __construct( $_path, $_urlCaseSensitive = false ) {
9
-      if(!is_string($_path))
10
-        throw new JException("Parameter must be a string.");
9
+      if(!is_string($_path)) {
10
+              throw new JException("Parameter must be a string.");
11
+      }
11 12
       $jConfig   = new JConfig($_path);
12 13
       $server    = new ServerVars();
13 14
       $request   = $server->server["REQUEST_URI"];
@@ -24,8 +25,9 @@  discard block
 block discarded – undo
24 25
       foreach ($this->pages as $page) {
25 26
         $urlParameters = $this->pathSeeker(explode("/", $page[0]), $this->url);
26 27
         if(is_array($urlParameters)) {
27
-          if(isset($page[2]) && is_array($page[2]))
28
-            $urlParameters = array_merge($urlParameters, $page[2]);
28
+          if(isset($page[2]) && is_array($page[2])) {
29
+                      $urlParameters = array_merge($urlParameters, $page[2]);
30
+          }
29 31
           $pageSelected = [
30 32
             $page[1],
31 33
             $urlParameters
@@ -33,10 +35,11 @@  discard block
 block discarded – undo
33 35
           break;
34 36
         }
35 37
       }
36
-      if( $pageSelected !== null )
37
-        return $pageSelected;
38
-      else
39
-        return $this->defaultPage;
38
+      if( $pageSelected !== null ) {
39
+              return $pageSelected;
40
+      } else {
41
+              return $this->defaultPage;
42
+      }
40 43
     }
41 44
     protected function pathSeeker( $_path, $_url ) {
42 45
       $urlLength = count($_url);
@@ -47,15 +50,18 @@  discard block
 block discarded – undo
47 50
         while($cont < $urlLength) {
48 51
           if(
49 52
             ($this->urlCaseSensitive && $_path[$cont] == $_url[$cont]) ||
50
-            (!$this->urlCaseSensitive && strtolower($_path[$cont]) == strtolower($_url[$cont])) )
51
-            $cont++;
52
-          else if( strpos($_path[$cont], "\$") !== false ) {
53
+            (!$this->urlCaseSensitive && strtolower($_path[$cont]) == strtolower($_url[$cont])) ) {
54
+                      $cont++;
55
+          } else if( strpos($_path[$cont], "\$") !== false ) {
53 56
             $variables[str_replace('$', "", $_path[$cont])] = $_url[$cont];
54 57
             $cont++;
55
-          } else break;
58
+          } else {
59
+          	break;
60
+          }
61
+        }
62
+        if($cont == $urlLength) {
63
+                  return $variables;
56 64
         }
57
-        if($cont == $urlLength)
58
-          return $variables;
59 65
       }
60 66
       return null;
61 67
     }
Please login to merge, or discard this patch.
dist/jate/modules/Html/Html.php 1 patch
Braces   +33 added lines, -22 removed lines patch added patch discarded remove patch
@@ -27,8 +27,9 @@  discard block
 block discarded – undo
27 27
     }
28 28
     abstract public function init();
29 29
     public function draw() {
30
-      if($this->template == "")
31
-        throw new JException("The variable \$this->template must be set in class $this->name function init().");
30
+      if($this->template == "") {
31
+              throw new JException("The variable \$this->template must be set in class $this->name function init().");
32
+      }
32 33
       $server = new ServerVars();
33 34
       $this->addDipendences();
34 35
       $this->tags["css"]  = array_unique($this->tags["css"]);
@@ -47,34 +48,41 @@  discard block
 block discarded – undo
47 48
       return $this->jsVars;
48 49
     }
49 50
     public function addJsVar( $_name, $_value ) {
50
-      if(!is_string($_name))
51
-        throw new InvalidArgumentException("Parameter name must be a string.");
52
-      if(!is_string($_value))
53
-        throw new InvalidArgumentException("Parameter value must be a string.");
51
+      if(!is_string($_name)) {
52
+              throw new InvalidArgumentException("Parameter name must be a string.");
53
+      }
54
+      if(!is_string($_value)) {
55
+              throw new InvalidArgumentException("Parameter value must be a string.");
56
+      }
54 57
       $this->jsVars[] = [$_name, $_value];
55 58
     }
56 59
     public function addJsVars( $_array ) {
57
-      if(!is_array($_array))
58
-        throw new InvalidArgumentException("Parameter must be an array.");
59
-      foreach ($_array as $value)
60
-        $this->addJsVar($value[0], $value[1]);
60
+      if(!is_array($_array)) {
61
+              throw new InvalidArgumentException("Parameter must be an array.");
62
+      }
63
+      foreach ($_array as $value) {
64
+              $this->addJsVar($value[0], $value[1]);
65
+      }
61 66
     }
62 67
     protected function stringifyDipendences() {
63 68
       $tempStr = "";
64 69
       $timeParameter = "?t=".time();
65 70
       $time = ($this->app->cache->css == true) ? "" : $timeParameter;
66
-      foreach ($this->tags["css"] as $i)
67
-      $tempStr .= "<link rel='stylesheet' href='$i$time'>";
71
+      foreach ($this->tags["css"] as $i) {
72
+            $tempStr .= "<link rel='stylesheet' href='$i$time'>";
73
+      }
68 74
       $this->tags["css"] = $tempStr;
69 75
       $tempStr = "";
70 76
       $time = ($this->app->cache->js == true) ? "" : $timeParameter;
71
-      foreach ($this->tags["js"] as $i)
72
-      $tempStr .= "<script src='$i$time'></script>";
77
+      foreach ($this->tags["js"] as $i) {
78
+            $tempStr .= "<script src='$i$time'></script>";
79
+      }
73 80
       $this->tags["js"] = $tempStr;
74 81
       $tempStr = "";
75 82
       $tempStr .= "<script type='text/javascript'>";
76
-      foreach ($this->tags["jsVar"] as $i)
77
-      $tempStr .= " $i[0] = $i[1];\n";
83
+      foreach ($this->tags["jsVar"] as $i) {
84
+            $tempStr .= " $i[0] = $i[1];\n";
85
+      }
78 86
       $tempStr .= "</script>";
79 87
       $this->tags["jsVar"] = $tempStr;
80 88
     }
@@ -87,14 +95,17 @@  discard block
 block discarded – undo
87 95
       $temp = [];
88 96
       $filesRequired = $this->getFilesRequired();
89 97
       $files         = $this->getFiles();
90
-      foreach ($filesRequired as $i)
91
-        if (!is_array($i) && strpos($i, $_extenction) !== FALSE)
98
+      foreach ($filesRequired as $i) {
99
+              if (!is_array($i) && strpos($i, $_extenction) !== FALSE)
92 100
           $temp[] = $i;
93
-      foreach ($this->modules as $i)
94
-        $temp = array_merge( $temp, $i->$_function() );
95
-      foreach ($files as $i)
96
-        if (!is_array($i) && strpos($i, $_extenction) !== FALSE)
101
+      }
102
+      foreach ($this->modules as $i) {
103
+              $temp = array_merge( $temp, $i->$_function() );
104
+      }
105
+      foreach ($files as $i) {
106
+              if (!is_array($i) && strpos($i, $_extenction) !== FALSE)
97 107
           $temp[] = $i;
108
+      }
98 109
       return $temp;
99 110
     }
100 111
   }
Please login to merge, or discard this patch.
dist/jate/modules/Module/Module.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -17,19 +17,24 @@
 block discarded – undo
17 17
       $this->__fileConstruct();
18 18
     }
19 19
     public function addModules( $_modules ) {
20
-      if(!is_array($_modules))
21
-        throw new JException("Parameter must be an array.");
22
-      foreach ($_modules as $value)
23
-        $this->addModule($value);
20
+      if(!is_array($_modules)) {
21
+              throw new JException("Parameter must be an array.");
22
+      }
23
+      foreach ($_modules as $value) {
24
+              $this->addModule($value);
25
+      }
24 26
     }
25 27
     public function addModule( $_module ) {
26
-      if(!is_object($_module))
27
-        throw new JException("Parameter must be a object.");
28
-      if(! is_subclass_of ($_module, "Module"))
29
-        throw new JException("Parameter must be a object inherited from Module object.");
28
+      if(!is_object($_module)) {
29
+              throw new JException("Parameter must be a object.");
30
+      }
31
+      if(! is_subclass_of ($_module, "Module")) {
32
+              throw new JException("Parameter must be a object inherited from Module object.");
33
+      }
30 34
       $this->modules[$_module->name] = $_module;
31
-      if($this->currentConnection)
32
-        $this->modules[$_module->name]->addConnectionMan($this->currentConnection);
35
+      if($this->currentConnection) {
36
+              $this->modules[$_module->name]->addConnectionMan($this->currentConnection);
37
+      }
33 38
     }
34 39
   }
35 40
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/JConfig/JConfig.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,19 +1,24 @@
 block discarded – undo
1 1
 <?php
2 2
   class JConfig {
3 3
     public function __construct( $_path ) {
4
-      if(!is_string($_path))
5
-        throw new JException("Path must be a string.");
6
-      if(!file_exists($_path))
7
-        throw new JException("File [$_path] not found.");
4
+      if(!is_string($_path)) {
5
+              throw new JException("Path must be a string.");
6
+      }
7
+      if(!file_exists($_path)) {
8
+              throw new JException("File [$_path] not found.");
9
+      }
8 10
       $data = file_get_contents($_path);
9 11
       $data = json_decode($data);
10
-      if($data === NULL)
11
-        throw new JException("Invalid file data. [$_path]");
12
-      if(is_object($data))
13
-        foreach (get_object_vars($data) as $key => $value)
12
+      if($data === NULL) {
13
+              throw new JException("Invalid file data. [$_path]");
14
+      }
15
+      if(is_object($data)) {
16
+              foreach (get_object_vars($data) as $key => $value)
14 17
           $this->$key = $value;
15
-      if(is_array($data))
16
-        $this->data = $data;
18
+      }
19
+      if(is_array($data)) {
20
+              $this->data = $data;
21
+      }
17 22
     }
18 23
   }
19 24
 ?>
Please login to merge, or discard this patch.