Completed
Push — master ( a847da...ede37a )
by Federico
03:15
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/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.
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,
@@ -40,9 +41,10 @@  discard block
 block discarded – undo
40 41
     }
41 42
     protected function getConnectionType( $_type ) {
42 43
       $array = (array)$_type;
43
-      foreach ($array as $key => $value)
44
-        if($value)
44
+      foreach ($array as $key => $value) {
45
+              if($value)
45 46
           return $key;
47
+      }
46 48
       return "pdo";
47 49
     }
48 50
   }
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/Query/Query.php 1 patch
Braces   +45 added lines, -30 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,30 +24,36 @@  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);
48
-      if($this->currentConnection == null)
49
-        throw new JException("No connection selected.", 1);
51
+      if(!is_string($_query)) {
52
+              throw new JException("Parameter must be a string.", 1);
53
+      }
54
+      if($this->currentConnection == null) {
55
+              throw new JException("No connection selected.", 1);
56
+      }
50 57
       try {
51 58
         $temp = $this->currentConnection->database->query($_query);
52 59
       } catch (Exception $e) {
@@ -55,10 +62,12 @@  discard block
 block discarded – undo
55 62
       return $temp;
56 63
     }
57 64
     public function queryInsert( $_query ) {
58
-      if(!is_string($_query))
59
-        throw new JException("Parameter must be a string.", 1);
60
-      if($this->currentConnection == null)
61
-        throw new JException("No connection selected.", 1);
65
+      if(!is_string($_query)) {
66
+              throw new JException("Parameter must be a string.", 1);
67
+      }
68
+      if($this->currentConnection == null) {
69
+              throw new JException("No connection selected.", 1);
70
+      }
62 71
       try {
63 72
         $temp = $this->currentConnection->database->queryInsert($_query);
64 73
       } catch (Exception $e) {
@@ -67,10 +76,12 @@  discard block
 block discarded – undo
67 76
       return $temp;
68 77
     }
69 78
     public function queryFetch( $_query ) {
70
-      if(!is_string($_query))
71
-        throw new JException("Parameter must be a string.", 1);
72
-      if($this->currentConnection == null)
73
-        throw new JException("No connection selected.", 1);
79
+      if(!is_string($_query)) {
80
+              throw new JException("Parameter must be a string.", 1);
81
+      }
82
+      if($this->currentConnection == null) {
83
+              throw new JException("No connection selected.", 1);
84
+      }
74 85
       try {
75 86
         $temp = $this->currentConnection->database->queryFetch($_query);
76 87
       } catch (Exception $e) {
@@ -79,10 +90,12 @@  discard block
 block discarded – undo
79 90
       return $temp;
80 91
     }
81 92
     public function queryArray( $_query ) {
82
-      if(!is_string($_query))
83
-        throw new JException("Parameter must be a string.", 1);
84
-      if($this->currentConnection == null)
85
-        throw new JException("No connection selected.", 1);
93
+      if(!is_string($_query)) {
94
+              throw new JException("Parameter must be a string.", 1);
95
+      }
96
+      if($this->currentConnection == null) {
97
+              throw new JException("No connection selected.", 1);
98
+      }
86 99
       try {
87 100
         $temp = $this->currentConnection->database->queryArray($_query);
88 101
       } catch (Exception $e) {
@@ -91,10 +104,12 @@  discard block
 block discarded – undo
91 104
       return $temp;
92 105
     }
93 106
     public function newTable( $_query ) {
94
-      if(!is_string($_query))
95
-        throw new JException("Parameter must be a string.", 1);
96
-      if($this->currentConnection == null)
97
-        throw new JException("No connection selected.", 1);
107
+      if(!is_string($_query)) {
108
+              throw new JException("Parameter must be a string.", 1);
109
+      }
110
+      if($this->currentConnection == null) {
111
+              throw new JException("No connection selected.", 1);
112
+      }
98 113
       try {
99 114
         $temp = $this->currentConnection->database->newTable($_query);
100 115
       } catch (Exception $e) {
Please login to merge, or discard this patch.