Test Failed
Push — master ( cc6e3b...03f570 )
by Federico
02:11
created
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/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/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.
dist/jate/modules/Connection/Adapters/PdoAdapterMysql.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,14 +30,15 @@
 block discarded – undo
30 30
         $database = $this->connection;
31 31
         $query = $database->prepare($_query);
32 32
         $result = $query->execute();
33
-        if(!$result)
34
-          throw new JException(json_encode([
33
+        if(!$result) {
34
+                  throw new JException(json_encode([
35 35
             "query" => $_query,
36 36
             "error" => [
37 37
               $query->errorInfo(),
38 38
               $database->errorInfo()
39 39
             ]
40 40
           ]));
41
+        }
41 42
         return $query;
42 43
       }
43 44
   }
Please login to merge, or discard this patch.
dist/jate/modules/Connection/Connection.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,9 @@  discard block
 block discarded – undo
4 4
     public $database;
5 5
     public $info;
6 6
     public function __construct( $_object ) {
7
-      if(!is_object($_object))
8
-        throw new JException("Parameter must be an object.");
7
+      if(!is_object($_object)) {
8
+              throw new JException("Parameter must be an object.");
9
+      }
9 10
       $this->setConnection(
10 11
         $_object->server,
11 12
         $_object->database,
@@ -43,9 +44,10 @@  discard block
 block discarded – undo
43 44
     }
44 45
     protected function getConnectionType( $_type ) {
45 46
       $array = (array)$_type;
46
-      foreach ($array as $key => $value)
47
-        if($value)
47
+      foreach ($array as $key => $value) {
48
+              if($value)
48 49
           return $key;
50
+      }
49 51
       return "default";
50 52
     }
51 53
   }
Please login to merge, or discard this patch.
dist/jate/modules/Query/Query.php 1 patch
Braces   +42 added lines, -28 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,8 +24,9 @@  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;
@@ -33,17 +35,21 @@  discard block
 block discarded – undo
33 35
       }
34 36
     }
35 37
     public function setConnection( $_name = "default" ) {
36
-      if(!is_string($_name))
37
-        throw new JException("Parameter must be a string.", 1);
38
-      if(!isset($this->connection["$_name"]))
39
-        throw new JException("This connection name does not exist.", 1);
38
+      if(!is_string($_name)) {
39
+              throw new JException("Parameter must be a string.", 1);
40
+      }
41
+      if(!isset($this->connection["$_name"])) {
42
+              throw new JException("This connection name does not exist.", 1);
43
+      }
40 44
       $this->currentConnection = $this->connection["$_name"];
41 45
     }
42 46
     public function query( $_query ) {
43
-      if(!is_string($_query))
44
-        throw new JException("Parameter must be a string.", 1);
45
-      if($this->currentConnection == null)
46
-        throw new JException("No connection selected.", 1);
47
+      if(!is_string($_query)) {
48
+              throw new JException("Parameter must be a string.", 1);
49
+      }
50
+      if($this->currentConnection == null) {
51
+              throw new JException("No connection selected.", 1);
52
+      }
47 53
       try {
48 54
         $temp = $this->currentConnection->database->query($_query);
49 55
       } catch (Exception $e) {
@@ -52,10 +58,12 @@  discard block
 block discarded – undo
52 58
       return $temp;
53 59
     }
54 60
     public function queryInsert( $_query ) {
55
-      if(!is_string($_query))
56
-        throw new JException("Parameter must be a string.", 1);
57
-      if($this->currentConnection == null)
58
-        throw new JException("No connection selected.", 1);
61
+      if(!is_string($_query)) {
62
+              throw new JException("Parameter must be a string.", 1);
63
+      }
64
+      if($this->currentConnection == null) {
65
+              throw new JException("No connection selected.", 1);
66
+      }
59 67
       try {
60 68
         $temp = $this->currentConnection->database->queryInsert($_query);
61 69
       } catch (Exception $e) {
@@ -64,10 +72,12 @@  discard block
 block discarded – undo
64 72
       return $temp;
65 73
     }
66 74
     public function queryFetch( $_query ) {
67
-      if(!is_string($_query))
68
-        throw new JException("Parameter must be a string.", 1);
69
-      if($this->currentConnection == null)
70
-        throw new JException("No connection selected.", 1);
75
+      if(!is_string($_query)) {
76
+              throw new JException("Parameter must be a string.", 1);
77
+      }
78
+      if($this->currentConnection == null) {
79
+              throw new JException("No connection selected.", 1);
80
+      }
71 81
       try {
72 82
         $temp = $this->currentConnection->database->queryFetch($_query);
73 83
       } catch (Exception $e) {
@@ -76,10 +86,12 @@  discard block
 block discarded – undo
76 86
       return $temp;
77 87
     }
78 88
     public function queryArray( $_query ) {
79
-      if(!is_string($_query))
80
-        throw new JException("Parameter must be a string.", 1);
81
-      if($this->currentConnection == null)
82
-        throw new JException("No connection selected.", 1);
89
+      if(!is_string($_query)) {
90
+              throw new JException("Parameter must be a string.", 1);
91
+      }
92
+      if($this->currentConnection == null) {
93
+              throw new JException("No connection selected.", 1);
94
+      }
83 95
       try {
84 96
         $temp = $this->currentConnection->database->queryArray($_query);
85 97
       } catch (Exception $e) {
@@ -88,10 +100,12 @@  discard block
 block discarded – undo
88 100
       return $temp;
89 101
     }
90 102
     public function newTable( $_query ) {
91
-      if(!is_string($_query))
92
-        throw new JException("Parameter must be a string.", 1);
93
-      if($this->currentConnection == null)
94
-        throw new JException("No connection selected.", 1);
103
+      if(!is_string($_query)) {
104
+              throw new JException("Parameter must be a string.", 1);
105
+      }
106
+      if($this->currentConnection == null) {
107
+              throw new JException("No connection selected.", 1);
108
+      }
95 109
       try {
96 110
         $temp = $this->currentConnection->database->newTable($_query);
97 111
       } catch (Exception $e) {
Please login to merge, or discard this patch.
dist/jate/modules/Module/Module.php 1 patch
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -18,26 +18,32 @@
 block discarded – undo
18 18
       $this->__fileConstruct();
19 19
     }
20 20
     public function addModules( $_modules ) {
21
-      if(!is_array($_modules))
22
-        throw new JException("Parameter must be an array.");
23
-      foreach ($_modules as $value)
24
-        $this->addModule($value);
21
+      if(!is_array($_modules)) {
22
+              throw new JException("Parameter must be an array.");
23
+      }
24
+      foreach ($_modules as $value) {
25
+              $this->addModule($value);
26
+      }
25 27
     }
26 28
     public function addModule( $_module ) {
27
-      if(!is_object($_module))
28
-        throw new JException("Parameter must be a object.");
29
-      if(! is_subclass_of ($_module, "Module"))
30
-        throw new JException("Parameter must be a object inherited from Module object.");
29
+      if(!is_object($_module)) {
30
+              throw new JException("Parameter must be a object.");
31
+      }
32
+      if(! is_subclass_of ($_module, "Module")) {
33
+              throw new JException("Parameter must be a object inherited from Module object.");
34
+      }
31 35
       $this->modules[$_module->name] = $_module;
32
-      if($this->currentConnection)
33
-        $this->modules[$_module->name]->addConnectionMan($this->currentConnection);
36
+      if($this->currentConnection) {
37
+              $this->modules[$_module->name]->addConnectionMan($this->currentConnection);
38
+      }
34 39
     }
35 40
     public function addConnectionMan( $_connection, $_name = "default") {
36 41
       try {
37 42
         $this->__addConnectionMan($_connection, $_name);
38
-        foreach ($this->modules as &$module)
39
-          if(isset($this->currentConnection))
43
+        foreach ($this->modules as &$module) {
44
+                  if(isset($this->currentConnection))
40 45
             $module->addConnectionMan($this->currentConnection, $_name);
46
+        }
41 47
       } catch (Exception $e) {
42 48
         throw new JException($e->getMessage(), 1);
43 49
       }
Please login to merge, or discard this patch.