Test Failed
Push — master ( 83731f...b6308e )
by Federico
02:27
created
dist/jate/modules/Connection/Adapters/PostgresqlAdapter.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -1,48 +1,48 @@
 block discarded – undo
1 1
 <?php
2 2
   jRequire("ConnectionInterface.php");
3 3
   class PostgresqlAdapter implements ConnectionAdapterInterface {
4
-      public $connection;
5
-      public function __construct( $_srv, $_db, $_usr, $_pass ) {
6
-        try {
7
-          $this->connection = pg_connect("host=$_srv dbname=$_db user=$_usr password=$_pass")
8
-            or die('Could not connect: '.pg_last_error());
9
-        } catch( Exception $e ) {
10
-          throw new JException($e->getMessage());
11
-        }
12
-      }
13
-      public function query( $_query ) {
14
-        $this->stdQuery($_query);
15
-        return true;
16
-      }
17
-      public function queryInsert( $_query ) {
18
-        $this->stdQuery($_query);
19
-        return $this->stdQuery("SELECT lastval()");
20
-      }
21
-      public function queryFetch( $_query ) {
22
-        $result = $this->stdQuery($_query);
23
-        $rows = [];
24
-        while($row = pg_fetch_assoc($result))
25
-          $rows[] = $row;
26
-        pg_free_result($result);
27
-        return $rows;
28
-      }
29
-      public function queryArray( $_query ) {
30
-        $result = $this->stdQuery($_query);
31
-        $rows = [];
32
-        while($row = pg_fetch_array($result))
33
-          $rows[] = $row;
34
-        pg_free_result($result);
35
-        return $rows;
36
-      }
37
-      protected function stdQuery( $_query ) {
38
-        $database = $this->connection;
39
-        $result = pg_query($database, $_query);
40
-        if(!$result)
41
-          throw new JException(json_encode([
42
-            "query" => $_query,
43
-            "error" => pg_last_error()
44
-          ]));
45
-        return $result;
46
-      }
4
+	  public $connection;
5
+	  public function __construct( $_srv, $_db, $_usr, $_pass ) {
6
+		try {
7
+		  $this->connection = pg_connect("host=$_srv dbname=$_db user=$_usr password=$_pass")
8
+			or die('Could not connect: '.pg_last_error());
9
+		} catch( Exception $e ) {
10
+		  throw new JException($e->getMessage());
11
+		}
12
+	  }
13
+	  public function query( $_query ) {
14
+		$this->stdQuery($_query);
15
+		return true;
16
+	  }
17
+	  public function queryInsert( $_query ) {
18
+		$this->stdQuery($_query);
19
+		return $this->stdQuery("SELECT lastval()");
20
+	  }
21
+	  public function queryFetch( $_query ) {
22
+		$result = $this->stdQuery($_query);
23
+		$rows = [];
24
+		while($row = pg_fetch_assoc($result))
25
+		  $rows[] = $row;
26
+		pg_free_result($result);
27
+		return $rows;
28
+	  }
29
+	  public function queryArray( $_query ) {
30
+		$result = $this->stdQuery($_query);
31
+		$rows = [];
32
+		while($row = pg_fetch_array($result))
33
+		  $rows[] = $row;
34
+		pg_free_result($result);
35
+		return $rows;
36
+	  }
37
+	  protected function stdQuery( $_query ) {
38
+		$database = $this->connection;
39
+		$result = pg_query($database, $_query);
40
+		if(!$result)
41
+		  throw new JException(json_encode([
42
+			"query" => $_query,
43
+			"error" => pg_last_error()
44
+		  ]));
45
+		return $result;
46
+	  }
47 47
   }
48 48
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Connection/Adapters/PdoMemoryAdapter.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
   jRequire("PdoAdapter.php");
3 3
   class PdoMemoryAdapter extends PdoAdapter {
4
-      public $connection;
5
-      public function __construct( $_srv, $_db, $_usr, $_pass ) {
6
-        try {
7
-          $this->connection = new PDO("sqlite::memory:");
8
-        } catch( Exception $e ) {
9
-          throw new JException($e->getMessage());
10
-        }
11
-      }
4
+	  public $connection;
5
+	  public function __construct( $_srv, $_db, $_usr, $_pass ) {
6
+		try {
7
+		  $this->connection = new PDO("sqlite::memory:");
8
+		} catch( Exception $e ) {
9
+		  throw new JException($e->getMessage());
10
+		}
11
+	  }
12 12
   }
13 13
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Parser/Adapters/PugAdapter.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@
 block discarded – undo
2 2
   use Pug as Pug;
3 3
   jRequire("ParserAbstract.php");
4 4
   class PugAdapter extends ParserAbstract {
5
-    public function draw( $_text, $_parameters = [] ) {
6
-      $pug = new Pug\Pug();
7
-      $page = $pug->render($_text, $_parameters);
8
-      return $page;
9
-    }
5
+	public function draw( $_text, $_parameters = [] ) {
6
+	  $pug = new Pug\Pug();
7
+	  $page = $pug->render($_text, $_parameters);
8
+	  return $page;
9
+	}
10 10
   }
11 11
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Parser/Adapters/JTagAdapter.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
   jRequire("ParserAbstract.php");
3 3
   class JTagAdapter extends ParserAbstract {
4
-    public function draw( $_text, $_parameters = [] ) {
5
-      foreach($_parameters as $key => $value)
6
-        if(!is_array($value))
7
-          $_text = str_replace("<_${key}_>", "$value", $_text);
8
-      $_text = preg_replace('~<_[^_]+_>~', '', $_text);
9
-      return $_text;
10
-    }
4
+	public function draw( $_text, $_parameters = [] ) {
5
+	  foreach($_parameters as $key => $value)
6
+		if(!is_array($value))
7
+		  $_text = str_replace("<_${key}_>", "$value", $_text);
8
+	  $_text = preg_replace('~<_[^_]+_>~', '', $_text);
9
+	  return $_text;
10
+	}
11 11
   }
12 12
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Parser/Adapters/TwigAdapter.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,13 +2,13 @@
 block discarded – undo
2 2
   // use Twig as Twig;
3 3
   jRequire("ParserAbstract.php");
4 4
   class TwigAdapter extends ParserAbstract {
5
-    public function draw( $_text, $_parameters = [] ) {
6
-      $loader = new Twig_Loader_Array([
7
-        'index' => $_text
8
-      ]);
9
-      $twig = new Twig_Environment($loader);
10
-      $page = $twig->render('index', $_parameters);
11
-      return $page;
12
-    }
5
+	public function draw( $_text, $_parameters = [] ) {
6
+	  $loader = new Twig_Loader_Array([
7
+		'index' => $_text
8
+	  ]);
9
+	  $twig = new Twig_Environment($loader);
10
+	  $page = $twig->render('index', $_parameters);
11
+	  return $page;
12
+	}
13 13
   }
14 14
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Parser/Adapters/ParserAbstract.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
   abstract class ParserAbstract {
3
-    public function drawText( $_text, $_parameters = [] ) {
4
-      return $this->draw(trim($_text), $_parameters);
5
-    }
6
-    abstract public function draw( $_text, $_parameters = [] );
3
+	public function drawText( $_text, $_parameters = [] ) {
4
+	  return $this->draw(trim($_text), $_parameters);
5
+	}
6
+	abstract public function draw( $_text, $_parameters = [] );
7 7
   }
8 8
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Parser/Adapters/ParsedownAdapter.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@
 block discarded – undo
3 3
   jRequire("../../ExternalModules/Parsedown/Parsedown.php");
4 4
   use Parsedown as Parsedown;
5 5
   class ParsedownAdapter extends ParserAbstract {
6
-    public function draw( $_text, $_parameters = [] ) {
7
-      $Parsedown = new Parsedown\Parsedown();
8
-      $page = $Parsedown->text($_text);
9
-      $page = preg_replace('/[ ](?=[^>]*(?:<|$))/', "&nbsp", $page);
10
-      return $page;
11
-    }
6
+	public function draw( $_text, $_parameters = [] ) {
7
+	  $Parsedown = new Parsedown\Parsedown();
8
+	  $page = $Parsedown->text($_text);
9
+	  $page = preg_replace('/[ ](?=[^>]*(?:<|$))/', "&nbsp", $page);
10
+	  return $page;
11
+	}
12 12
   }
13 13
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/Parser/Parser.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -2,66 +2,66 @@
 block discarded – undo
2 2
   requireComponents("Adapters");
3 3
   jRequire("../JException/JException.php");
4 4
   class Parser {
5
-    private static function setParser ( $_type ) {
6
-      $parser = null;
7
-      $_type = strtolower($_type);
8
-      switch ($_type) {
9
-        case "twig":
10
-          $parser = new TwigAdapter();
11
-        break;
12
-        case "jate":
13
-          $parser = new JTagAdapter();
14
-        break;
15
-        case 'jade':
16
-        case "pug":
17
-          $parser = new PugAdapter();
18
-        break;
19
-        case "md":
20
-        case "markdown":
21
-        case "parsedown":
22
-          $parser = new ParsedownAdapter();
23
-        break;
24
-        default:
25
-          $parser = -1;
26
-        break;
27
-      }
28
-      return $parser;
29
-    }
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.");
35
-      $parser = self::setParser($_type);
36
-      if($parser === -1)
37
-        return $_text;
38
-      return $parser->drawText($_text, $_parameters);
39
-    }
40
-    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.");
45
-      $string = file_get_contents($_path);
46
-      try {
47
-        $text = self::parseText($string, $_parameters, $_type);
48
-      } catch (Exception $e) {
49
-        throw new JException($e->getMessage());
50
-      }
51
-      return $text;
52
-    }
53
-    public static function parseFile( $_path, $_parameters = [] ) {
54
-      if(!is_string($_path))
55
-        throw new JException("Parameter must be a string.");
56
-      $extension = explode(".", $_path);
57
-      $extension = $extension[count($extension)-1];
58
-      $extension = strtolower($extension);
59
-      try {
60
-        $text = self::parseFileMan($_path, $_parameters, $extension);
61
-      } catch (Exception $e) {
62
-        throw new JException($e->getMessage());
63
-      }
64
-      return $text;
65
-    }
5
+	private static function setParser ( $_type ) {
6
+	  $parser = null;
7
+	  $_type = strtolower($_type);
8
+	  switch ($_type) {
9
+		case "twig":
10
+		  $parser = new TwigAdapter();
11
+		break;
12
+		case "jate":
13
+		  $parser = new JTagAdapter();
14
+		break;
15
+		case 'jade':
16
+		case "pug":
17
+		  $parser = new PugAdapter();
18
+		break;
19
+		case "md":
20
+		case "markdown":
21
+		case "parsedown":
22
+		  $parser = new ParsedownAdapter();
23
+		break;
24
+		default:
25
+		  $parser = -1;
26
+		break;
27
+	  }
28
+	  return $parser;
29
+	}
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.");
35
+	  $parser = self::setParser($_type);
36
+	  if($parser === -1)
37
+		return $_text;
38
+	  return $parser->drawText($_text, $_parameters);
39
+	}
40
+	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.");
45
+	  $string = file_get_contents($_path);
46
+	  try {
47
+		$text = self::parseText($string, $_parameters, $_type);
48
+	  } catch (Exception $e) {
49
+		throw new JException($e->getMessage());
50
+	  }
51
+	  return $text;
52
+	}
53
+	public static function parseFile( $_path, $_parameters = [] ) {
54
+	  if(!is_string($_path))
55
+		throw new JException("Parameter must be a string.");
56
+	  $extension = explode(".", $_path);
57
+	  $extension = $extension[count($extension)-1];
58
+	  $extension = strtolower($extension);
59
+	  try {
60
+		$text = self::parseFileMan($_path, $_parameters, $extension);
61
+	  } catch (Exception $e) {
62
+		throw new JException($e->getMessage());
63
+	  }
64
+	  return $text;
65
+	}
66 66
   }
67 67
 ?>
Please login to merge, or discard this patch.
dist/jate/modules/JException/JException.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php
2 2
   class JException extends Exception {
3
-    static protected $escapeString = "|jate|";
4
-    public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) {
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"];
14
-    }
15
-    public function __toString() {
16
-      return JException::encode(JException::decode($this->message));
17
-    }
18
-    static public function decode( $_message ) {
19
-      $messageSplitted = explode(JException::$escapeString, $_message);
20
-      if(count($messageSplitted) == 3)
21
-        return $messageSplitted[1];
22
-      else
23
-        return $_message;
24
-    }
25
-    static public function encode( $_message ) {
26
-      $escape = JException::$escapeString;
27
-      return "$escape$_message$escape";
3
+	static protected $escapeString = "|jate|";
4
+	public function __construct($_message, $_level = 2, $_code = 0, Exception $_previous = null) {
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"];
14
+	}
15
+	public function __toString() {
16
+	  return JException::encode(JException::decode($this->message));
17
+	}
18
+	static public function decode( $_message ) {
19
+	  $messageSplitted = explode(JException::$escapeString, $_message);
20
+	  if(count($messageSplitted) == 3)
21
+		return $messageSplitted[1];
22
+	  else
23
+		return $_message;
24
+	}
25
+	static public function encode( $_message ) {
26
+	  $escape = JException::$escapeString;
27
+	  return "$escape$_message$escape";
28 28
 
29
-    }
29
+	}
30 30
   }
31 31
 ?>
Please login to merge, or discard this patch.