Passed
Branch master (8656ae)
by refat
03:19
created
App/Middleware/Admin/AuthenticateMiddleware.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 
27 27
     } else {
28 28
 
29
-      if (! in_array($request, $pagesWhenLogout)) $app->url->redirectTo('/');
29
+      if (!in_array($request, $pagesWhenLogout)) $app->url->redirectTo('/');
30 30
     }
31 31
 
32 32
     return $next;
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,28 +7,28 @@
 block discarded – undo
7 7
 
8 8
 class AuthenticateMiddleware implements Middleware
9 9
 {
10
-  public function handle(Application $app, $next)
11
-  {
12
-    $request = $app->request->url();
10
+	public function handle(Application $app, $next)
11
+	{
12
+		$request = $app->request->url();
13 13
 
14
-    $login = $app->load->model('Login');
14
+		$login = $app->load->model('Login');
15 15
 
16
-    $pagesWhenLogout = [
17
-      '/login',
18
-      '/login/submit',
19
-      '/registration',
20
-      '/registration/submit'
21
-    ];
16
+		$pagesWhenLogout = [
17
+			'/login',
18
+			'/login/submit',
19
+			'/registration',
20
+			'/registration/submit'
21
+		];
22 22
 
23
-    if ($login->isLogged()) {
23
+		if ($login->isLogged()) {
24 24
 
25
-      if (in_array($request, $pagesWhenLogout)) $app->url->redirectTo('/');
25
+			if (in_array($request, $pagesWhenLogout)) $app->url->redirectTo('/');
26 26
 
27
-    } else {
27
+		} else {
28 28
 
29
-      if (! in_array($request, $pagesWhenLogout)) $app->url->redirectTo('/');
30
-    }
29
+			if (! in_array($request, $pagesWhenLogout)) $app->url->redirectTo('/');
30
+		}
31 31
 
32
-    return $next;
33
-  }
32
+		return $next;
33
+	}
34 34
 }
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,11 +22,15 @@
 block discarded – undo
22 22
 
23 23
     if ($login->isLogged()) {
24 24
 
25
-      if (in_array($request, $pagesWhenLogout)) $app->url->redirectTo('/');
25
+      if (in_array($request, $pagesWhenLogout)) {
26
+      	$app->url->redirectTo('/');
27
+      }
26 28
 
27 29
     } else {
28 30
 
29
-      if (! in_array($request, $pagesWhenLogout)) $app->url->redirectTo('/');
31
+      if (! in_array($request, $pagesWhenLogout)) {
32
+      	$app->url->redirectTo('/');
33
+      }
30 34
     }
31 35
 
32 36
     return $next;
Please login to merge, or discard this patch.
Core/System/Session.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
   {
16 16
     ini_set('session.use_only_cookies', 1);
17 17
 
18
-    if (! session_id()) {
18
+    if (!session_id()) {
19 19
       session_start();
20 20
     }
21 21
   }
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -4,60 +4,60 @@
 block discarded – undo
4 4
 
5 5
 class Session
6 6
 {
7
-  private $app;
8
-
9
-  public function __construct(Application $app)
10
-  {
11
-    $this->app = $app;
12
-  }
13
-
14
-  public function start()
15
-  {
16
-    ini_set('session.use_only_cookies', 1);
17
-
18
-    if (! session_id()) {
19
-      session_start();
20
-    }
21
-  }
22
-
23
-  public function set($key, $value)
24
-  {
25
-    $_SESSION[$key] = $value;
26
-  }
27
-
28
-  public function get($key, $default = null)
29
-  {
30
-    return array_get($_SESSION, $key, $default);
31
-  }
32
-
33
-  public function pull($key)
34
-  {
35
-    $value = $this->get($key);
36
-
37
-    $this->remove($key);
38
-
39
-    return $value;
40
-  }
41
-
42
-  public function has($key)
43
-  {
44
-    return isset($_SESSION[$key]);
45
-  }
46
-
47
-  public function all()
48
-  {
49
-    return $_SESSION;
50
-  }
51
-
52
-  public function remove($key)
53
-  {
54
-    unset($_SESSION[$key]);
55
-  }
56
-
57
-  public function destroy()
58
-  {
59
-    session_destroy();
60
-
61
-    unset($_SESSION);
62
-  }
7
+	private $app;
8
+
9
+	public function __construct(Application $app)
10
+	{
11
+		$this->app = $app;
12
+	}
13
+
14
+	public function start()
15
+	{
16
+		ini_set('session.use_only_cookies', 1);
17
+
18
+		if (! session_id()) {
19
+			session_start();
20
+		}
21
+	}
22
+
23
+	public function set($key, $value)
24
+	{
25
+		$_SESSION[$key] = $value;
26
+	}
27
+
28
+	public function get($key, $default = null)
29
+	{
30
+		return array_get($_SESSION, $key, $default);
31
+	}
32
+
33
+	public function pull($key)
34
+	{
35
+		$value = $this->get($key);
36
+
37
+		$this->remove($key);
38
+
39
+		return $value;
40
+	}
41
+
42
+	public function has($key)
43
+	{
44
+		return isset($_SESSION[$key]);
45
+	}
46
+
47
+	public function all()
48
+	{
49
+		return $_SESSION;
50
+	}
51
+
52
+	public function remove($key)
53
+	{
54
+		unset($_SESSION[$key]);
55
+	}
56
+
57
+	public function destroy()
58
+	{
59
+		session_destroy();
60
+
61
+		unset($_SESSION);
62
+	}
63 63
 }
64 64
\ No newline at end of file
Please login to merge, or discard this patch.
Core/System/Cookie.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
     setcookie($key, $value, $expireTime, $this->path, '', false, true);
23 23
   }
24 24
 
25
-  public function get($key , $default = null)
25
+  public function get($key, $default = null)
26 26
   {
27 27
     return array_get($_COOKIE, $key, $default);
28 28
   }
Please login to merge, or discard this patch.
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -4,50 +4,50 @@
 block discarded – undo
4 4
 
5 5
 class Cookie
6 6
 {
7
-  private $app;
7
+	private $app;
8 8
 
9
-  private $path;
9
+	private $path;
10 10
 
11
-  public function __construct(Application $app)
12
-  {
13
-    $this->app = $app;
11
+	public function __construct(Application $app)
12
+	{
13
+		$this->app = $app;
14 14
 
15
-    $this->path = dirname($this->app->request->server('SCRIPT_NAME')) ?: '/';
16
-  }
15
+		$this->path = dirname($this->app->request->server('SCRIPT_NAME')) ?: '/';
16
+	}
17 17
 
18
-  public function set($key, $value, $hours = 1800)
19
-  {
20
-    $expireTime = $hours == -1 ? -1 : time() + $hours * 3600;
18
+	public function set($key, $value, $hours = 1800)
19
+	{
20
+		$expireTime = $hours == -1 ? -1 : time() + $hours * 3600;
21 21
 
22
-    setcookie($key, $value, $expireTime, $this->path, '', false, true);
23
-  }
22
+		setcookie($key, $value, $expireTime, $this->path, '', false, true);
23
+	}
24 24
 
25
-  public function get($key , $default = null)
26
-  {
27
-    return array_get($_COOKIE, $key, $default);
28
-  }
25
+	public function get($key , $default = null)
26
+	{
27
+		return array_get($_COOKIE, $key, $default);
28
+	}
29 29
 
30
-  public function has($key)
31
-  {
32
-    return array_key_exists($key, $_COOKIE);
33
-  }
30
+	public function has($key)
31
+	{
32
+		return array_key_exists($key, $_COOKIE);
33
+	}
34 34
 
35
-  public function remove($key)
36
-  {
37
-    $this->set($key, null, -1);
35
+	public function remove($key)
36
+	{
37
+		$this->set($key, null, -1);
38 38
 
39
-    unset($_COOKIE[$key]);
40
-  }
39
+		unset($_COOKIE[$key]);
40
+	}
41 41
 
42
-  public function all()
43
-  {
44
-    return $_COOKIE;
45
-  }
42
+	public function all()
43
+	{
44
+		return $_COOKIE;
45
+	}
46 46
 
47
-  public function destroy()
48
-  {
49
-    foreach (array_keys($this->all()) as $key) $this->remove($key);
47
+	public function destroy()
48
+	{
49
+		foreach (array_keys($this->all()) as $key) $this->remove($key);
50 50
 
51
-    unset($_COOKIE);
52
-  }
51
+		unset($_COOKIE);
52
+	}
53 53
 }
54 54
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,9 @@
 block discarded – undo
46 46
 
47 47
   public function destroy()
48 48
   {
49
-    foreach (array_keys($this->all()) as $key) $this->remove($key);
49
+    foreach (array_keys($this->all()) as $key) {
50
+    	$this->remove($key);
51
+    }
50 52
 
51 53
     unset($_COOKIE);
52 54
   }
Please login to merge, or discard this patch.
Core/System/Model.php 3 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 
36 36
   public function get($value, $coulmn = 'id')
37 37
   {
38
-    return $this->where($coulmn . ' = ?' , $value)->fetch($this->table);
38
+    return $this->where($coulmn . ' = ?', $value)->fetch($this->table);
39 39
   }
40 40
 
41 41
   public function getEnable($value, $coulmn = 'id')
42 42
   {
43
-    return $this->where($coulmn . ' = ? AND enable = ?' , [$value, 1])->fetch($this->table);
43
+    return $this->where($coulmn . ' = ? AND enable = ?', [$value, 1])->fetch($this->table);
44 44
   }
45 45
 
46 46
   public function selectTable($coulmn)
@@ -50,23 +50,23 @@  discard block
 block discarded – undo
50 50
 
51 51
   public function exists($value, $key = 'id')
52 52
   {
53
-    return (bool) $this->select($key)->where($key .'=?' , $value)->fetch($this->table);
53
+    return (bool) $this->select($key)->where($key . '=?', $value)->fetch($this->table);
54 54
   }
55 55
 
56 56
   public function delete($id)
57 57
   {
58
-    return $this->where('id = ?' , $id)->delete($this->table);
58
+    return $this->where('id = ?', $id)->delete($this->table);
59 59
   }
60 60
 
61 61
   public function hasOne($join, $id = null, $select = '*', $limit = null, $localId = null, $forginId = null)
62 62
   {
63 63
     $join = rtrim($join, 'Model');
64 64
 
65
-    $file = $this->app->file->to( 'App/Models/' . $join . 'Model', '.php');
65
+    $file = $this->app->file->to('App/Models/' . $join . 'Model', '.php');
66 66
 
67 67
     $exists = $this->app->file->exists($file);
68 68
 
69
-    if (! $exists) return $join . ' Not Found';
69
+    if (!$exists) return $join . ' Not Found';
70 70
 
71 71
     $trace = debug_backtrace();
72 72
 
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
   {
82 82
     $join = rtrim($join, 'Model');
83 83
 
84
-    $file = $this->app->file->to( 'App/Models/' . $join . 'Model', '.php');
84
+    $file = $this->app->file->to('App/Models/' . $join . 'Model', '.php');
85 85
 
86 86
     $exists = $this->app->file->exists($file);
87 87
 
88
-    if (! $exists) return $join . ' Not Found';
88
+    if (!$exists) return $join . ' Not Found';
89 89
 
90 90
     $trace = debug_backtrace();
91 91
 
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
   {
101 101
     $join = rtrim($join, 'Model');
102 102
 
103
-    $file = $this->app->file->to( 'App/Models/' . $join . 'Model', '.php');
103
+    $file = $this->app->file->to('App/Models/' . $join . 'Model', '.php');
104 104
 
105 105
     $exists = $this->app->file->exists($file);
106 106
 
107
-    if (! $exists) return $join . ' Not Found';
107
+    if (!$exists) return $join . ' Not Found';
108 108
 
109 109
     $trace = debug_backtrace();
110 110
 
Please login to merge, or discard this patch.
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -4,119 +4,119 @@
 block discarded – undo
4 4
 
5 5
 abstract class Model
6 6
 {
7
-  protected $app;
7
+	protected $app;
8 8
 
9
-  protected $table;
9
+	protected $table;
10 10
 
11
-  public function __construct(Application $app)
12
-  {
13
-    $this->app = $app;
14
-  }
11
+	public function __construct(Application $app)
12
+	{
13
+		$this->app = $app;
14
+	}
15 15
 
16
-  public function __get($key)
17
-  {
18
-    return $this->app->get($key);
19
-  }
16
+	public function __get($key)
17
+	{
18
+		return $this->app->get($key);
19
+	}
20 20
 
21
-  public function __call($method, $args)
22
-  {
23
-    return call_user_func_array([$this->app->db, $method], $args);
24
-  }
21
+	public function __call($method, $args)
22
+	{
23
+		return call_user_func_array([$this->app->db, $method], $args);
24
+	}
25 25
 
26
-  public function all($limit = null)
27
-  {
28
-    return $this->orderBy('id', 'DESC')->limit($limit)->fetchAll($this->table);
29
-  }
26
+	public function all($limit = null)
27
+	{
28
+		return $this->orderBy('id', 'DESC')->limit($limit)->fetchAll($this->table);
29
+	}
30 30
 
31
-  public function allEnable($limit = null)
32
-  {
33
-    return $this->orderBy('id', 'DESC')->where('enable = ?', 1)->limit($limit)->fetchAll($this->table);
34
-  }
31
+	public function allEnable($limit = null)
32
+	{
33
+		return $this->orderBy('id', 'DESC')->where('enable = ?', 1)->limit($limit)->fetchAll($this->table);
34
+	}
35 35
 
36
-  public function get($value, $coulmn = 'id')
37
-  {
38
-    return $this->where($coulmn . ' = ?' , $value)->fetch($this->table);
39
-  }
36
+	public function get($value, $coulmn = 'id')
37
+	{
38
+		return $this->where($coulmn . ' = ?' , $value)->fetch($this->table);
39
+	}
40 40
 
41
-  public function getEnable($value, $coulmn = 'id')
42
-  {
43
-    return $this->where($coulmn . ' = ? AND enable = ?' , [$value, 1])->fetch($this->table);
44
-  }
41
+	public function getEnable($value, $coulmn = 'id')
42
+	{
43
+		return $this->where($coulmn . ' = ? AND enable = ?' , [$value, 1])->fetch($this->table);
44
+	}
45 45
 
46
-  public function selectTable($coulmn)
47
-  {
48
-    return $this->select($coulmn)->fetchAll($this->table);
49
-  }
46
+	public function selectTable($coulmn)
47
+	{
48
+		return $this->select($coulmn)->fetchAll($this->table);
49
+	}
50 50
 
51
-  public function exists($value, $key = 'id')
52
-  {
53
-    return (bool) $this->select($key)->where($key .'=?' , $value)->fetch($this->table);
54
-  }
51
+	public function exists($value, $key = 'id')
52
+	{
53
+		return (bool) $this->select($key)->where($key .'=?' , $value)->fetch($this->table);
54
+	}
55 55
 
56
-  public function delete($id)
57
-  {
58
-    return $this->where('id = ?' , $id)->delete($this->table);
59
-  }
56
+	public function delete($id)
57
+	{
58
+		return $this->where('id = ?' , $id)->delete($this->table);
59
+	}
60 60
 
61
-  public function hasOne($join, $id = null, $select = '*', $limit = null, $localId = null, $forginId = null)
62
-  {
63
-    $join = rtrim($join, 'Model');
61
+	public function hasOne($join, $id = null, $select = '*', $limit = null, $localId = null, $forginId = null)
62
+	{
63
+		$join = rtrim($join, 'Model');
64 64
 
65
-    $file = $this->app->file->to( 'App/Models/' . $join . 'Model', '.php');
65
+		$file = $this->app->file->to( 'App/Models/' . $join . 'Model', '.php');
66 66
 
67
-    $exists = $this->app->file->exists($file);
67
+		$exists = $this->app->file->exists($file);
68 68
 
69
-    if (! $exists) return $join . ' Not Found';
69
+		if (! $exists) return $join . ' Not Found';
70 70
 
71
-    $trace = debug_backtrace();
71
+		$trace = debug_backtrace();
72 72
 
73
-    $table = $trace[1]['object']->table;
73
+		$table = $trace[1]['object']->table;
74 74
 
75
-    $join = $this->load->model($join)->table;
75
+		$join = $this->load->model($join)->table;
76 76
 
77
-    return $this->db->select($select)->from($table)->join($join, $localId, $forginId)->where($table . '.id = ?', $id)->limit($limit)->fetch();
78
-  }
77
+		return $this->db->select($select)->from($table)->join($join, $localId, $forginId)->where($table . '.id = ?', $id)->limit($limit)->fetch();
78
+	}
79 79
 
80
-  public function hasMany($join, $id = null, $select = '*', $limit = null, $localId = null, $forginId = null)
81
-  {
82
-    $join = rtrim($join, 'Model');
80
+	public function hasMany($join, $id = null, $select = '*', $limit = null, $localId = null, $forginId = null)
81
+	{
82
+		$join = rtrim($join, 'Model');
83 83
 
84
-    $file = $this->app->file->to( 'App/Models/' . $join . 'Model', '.php');
84
+		$file = $this->app->file->to( 'App/Models/' . $join . 'Model', '.php');
85 85
 
86
-    $exists = $this->app->file->exists($file);
86
+		$exists = $this->app->file->exists($file);
87 87
 
88
-    if (! $exists) return $join . ' Not Found';
88
+		if (! $exists) return $join . ' Not Found';
89 89
 
90
-    $trace = debug_backtrace();
90
+		$trace = debug_backtrace();
91 91
 
92
-    $table = $trace[1]['object']->table;
92
+		$table = $trace[1]['object']->table;
93 93
 
94
-    $join = $this->load->model($join)->table;
94
+		$join = $this->load->model($join)->table;
95 95
 
96
-    return $this->db->select($select)->from($table)->join($join, $localId, $forginId)->where($table . '.id = ?', $id)->limit($limit)->fetchAll();
97
-  }
96
+		return $this->db->select($select)->from($table)->join($join, $localId, $forginId)->where($table . '.id = ?', $id)->limit($limit)->fetchAll();
97
+	}
98 98
 
99
-  public function join($join, $limit = null, $enable = null, $localId = null, $forginId = null)
100
-  {
101
-    $join = rtrim($join, 'Model');
99
+	public function join($join, $limit = null, $enable = null, $localId = null, $forginId = null)
100
+	{
101
+		$join = rtrim($join, 'Model');
102 102
 
103
-    $file = $this->app->file->to( 'App/Models/' . $join . 'Model', '.php');
103
+		$file = $this->app->file->to( 'App/Models/' . $join . 'Model', '.php');
104 104
 
105
-    $exists = $this->app->file->exists($file);
105
+		$exists = $this->app->file->exists($file);
106 106
 
107
-    if (! $exists) return $join . ' Not Found';
107
+		if (! $exists) return $join . ' Not Found';
108 108
 
109
-    $trace = debug_backtrace();
109
+		$trace = debug_backtrace();
110 110
 
111
-    $table = $trace[1]['object']->table;
111
+		$table = $trace[1]['object']->table;
112 112
 
113
-    $join = $this->load->model($join)->table;
113
+		$join = $this->load->model($join)->table;
114 114
 
115
-    if ($enable) {
115
+		if ($enable) {
116 116
 
117
-      return $this->db->select()->from($table)->join($join, $localId, $forginId)->where('enable = ?', 1)->limit($limit)->fetchAll();
118
-    }
117
+			return $this->db->select()->from($table)->join($join, $localId, $forginId)->where('enable = ?', 1)->limit($limit)->fetchAll();
118
+		}
119 119
 
120
-    return $this->db->select()->from($table)->join($join, $localId, $forginId)->limit($limit)->fetchAll();
121
-  }
120
+		return $this->db->select()->from($table)->join($join, $localId, $forginId)->limit($limit)->fetchAll();
121
+	}
122 122
 }
123 123
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@  discard block
 block discarded – undo
66 66
 
67 67
     $exists = $this->app->file->exists($file);
68 68
 
69
-    if (! $exists) return $join . ' Not Found';
69
+    if (! $exists) {
70
+    	return $join . ' Not Found';
71
+    }
70 72
 
71 73
     $trace = debug_backtrace();
72 74
 
@@ -85,7 +87,9 @@  discard block
 block discarded – undo
85 87
 
86 88
     $exists = $this->app->file->exists($file);
87 89
 
88
-    if (! $exists) return $join . ' Not Found';
90
+    if (! $exists) {
91
+    	return $join . ' Not Found';
92
+    }
89 93
 
90 94
     $trace = debug_backtrace();
91 95
 
@@ -104,7 +108,9 @@  discard block
 block discarded – undo
104 108
 
105 109
     $exists = $this->app->file->exists($file);
106 110
 
107
-    if (! $exists) return $join . ' Not Found';
111
+    if (! $exists) {
112
+    	return $join . ' Not Found';
113
+    }
108 114
 
109 115
     $trace = debug_backtrace();
110 116
 
Please login to merge, or discard this patch.
Core/System/Loader.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
   {
31 31
     $controller = $this->getControllerName($controller);
32 32
 
33
-    if (! $this->hasController($controller)) {
33
+    if (!$this->hasController($controller)) {
34 34
       $this->addController($controller);
35 35
     }
36 36
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
     $controller = str_replace('/', DS, $controller);
62 62
 
63
-    $controller = 'App' . DS .'Controllers' . DS . $controller;
63
+    $controller = 'App' . DS . 'Controllers' . DS . $controller;
64 64
 
65 65
     return $controller;
66 66
   }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
   {
70 70
     $model = $this->getModelName($model);
71 71
 
72
-    if (! $this->hasModel($model)) {
72
+    if (!$this->hasModel($model)) {
73 73
       $this->addModel($model);
74 74
     }
75 75
 
Please login to merge, or discard this patch.
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -6,99 +6,99 @@
 block discarded – undo
6 6
 
7 7
 class Loader
8 8
 {
9
-  private $app;
9
+	private $app;
10 10
 
11
-  private $controllers = [];
11
+	private $controllers = [];
12 12
 
13
-  private $models = [];
13
+	private $models = [];
14 14
 
15
-  public function __construct(Application $app)
16
-  {
17
-    $this->app = $app;
18
-  }
15
+	public function __construct(Application $app)
16
+	{
17
+		$this->app = $app;
18
+	}
19 19
 
20
-  public function action($controller, $method, array $arguments)
21
-  {
22
-    $object = $this->controller($controller);
20
+	public function action($controller, $method, array $arguments)
21
+	{
22
+		$object = $this->controller($controller);
23 23
 
24
-    return call_user_func([$object, $method], $arguments);
25
-  }
24
+		return call_user_func([$object, $method], $arguments);
25
+	}
26 26
 
27
-  public function controller($controller)
28
-  {
29
-    $controller = $this->getControllerName($controller);
27
+	public function controller($controller)
28
+	{
29
+		$controller = $this->getControllerName($controller);
30 30
 
31
-    if (! $this->hasController($controller)) {
32
-      $this->addController($controller);
33
-    }
31
+		if (! $this->hasController($controller)) {
32
+			$this->addController($controller);
33
+		}
34 34
 
35
-    return $this->getController($controller);
36
-  }
35
+		return $this->getController($controller);
36
+	}
37 37
 
38
-  private function hasController($controller)
39
-  {
40
-    return array_key_exists($controller, $this->controllers);
41
-  }
38
+	private function hasController($controller)
39
+	{
40
+		return array_key_exists($controller, $this->controllers);
41
+	}
42 42
 
43
-  private function addController($controller)
44
-  {
45
-    $object = new $controller($this->app);
43
+	private function addController($controller)
44
+	{
45
+		$object = new $controller($this->app);
46 46
 
47
-    $this->controllers[$controller] = $object;
48
-  }
47
+		$this->controllers[$controller] = $object;
48
+	}
49 49
 
50
-  private function getController($controller)
51
-  {
52
-    return $this->controllers[$controller];
53
-  }
50
+	private function getController($controller)
51
+	{
52
+		return $this->controllers[$controller];
53
+	}
54 54
 
55
-  private function getControllerName($controller)
56
-  {
57
-    $controller .= strpos($controller, 'Controller') ? '' : 'Controller';
55
+	private function getControllerName($controller)
56
+	{
57
+		$controller .= strpos($controller, 'Controller') ? '' : 'Controller';
58 58
 
59
-    $controller = str_replace('/', DS, $controller);
59
+		$controller = str_replace('/', DS, $controller);
60 60
 
61
-    $controller = 'App' . DS .'Controllers' . DS . $controller;
61
+		$controller = 'App' . DS .'Controllers' . DS . $controller;
62 62
 
63
-    return $controller;
64
-  }
63
+		return $controller;
64
+	}
65 65
 
66
-  public function model($model)
67
-  {
68
-    $model = $this->getModelName($model);
66
+	public function model($model)
67
+	{
68
+		$model = $this->getModelName($model);
69 69
 
70
-    if (! $this->hasModel($model)) {
71
-      $this->addModel($model);
72
-    }
70
+		if (! $this->hasModel($model)) {
71
+			$this->addModel($model);
72
+		}
73 73
 
74
-    return $this->getModel($model);
75
-  }
74
+		return $this->getModel($model);
75
+	}
76 76
 
77
-  private function hasModel($model)
78
-  {
79
-    return array_key_exists($model, $this->models);
80
-  }
77
+	private function hasModel($model)
78
+	{
79
+		return array_key_exists($model, $this->models);
80
+	}
81 81
 
82
-  private function addModel($model)
83
-  {
84
-    $object = new $model($this->app);
82
+	private function addModel($model)
83
+	{
84
+		$object = new $model($this->app);
85 85
 
86
-    $this->models[$model] = $object;
87
-  }
86
+		$this->models[$model] = $object;
87
+	}
88 88
 
89
-  private function getModel($model)
90
-  {
91
-    return $this->models[$model];
92
-  }
89
+	private function getModel($model)
90
+	{
91
+		return $this->models[$model];
92
+	}
93 93
 
94
-  private function getModelName($model)
95
-  {
96
-    $model .= strpos($model, 'Model') ? '' : 'Model';
94
+	private function getModelName($model)
95
+	{
96
+		$model .= strpos($model, 'Model') ? '' : 'Model';
97 97
 
98
-    $model = str_replace('/', DS, $model);
98
+		$model = str_replace('/', DS, $model);
99 99
 
100
-    $model = 'App' . DS . 'Models' . DS . $model;
100
+		$model = 'App' . DS . 'Models' . DS . $model;
101 101
 
102
-    return $model;
103
-  }
102
+		return $model;
103
+	}
104 104
 }
105 105
\ No newline at end of file
Please login to merge, or discard this patch.
Core/System/PugView.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 
30 30
     //File Path
31 31
     $file = str_replace('/', DS, $path);
32
-    $file = $dir . DS . 'template' . DS  . $file . '.pug';
32
+    $file = $dir . DS . 'template' . DS . $file . '.pug';
33 33
 
34 34
     //Css Path
35 35
     $css = $this->app->file->css();
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -6,47 +6,47 @@
 block discarded – undo
6 6
 
7 7
 class PugView
8 8
 {
9
-  private $app;
10
-
11
-  public function __construct(Application $app)
12
-  {
13
-    $this->app = $app;
14
-  }
15
-
16
-  public function render($path, array $context)
17
-  {
18
-    $this->app->file->css();
19
-    $pug = new Pug(array(
20
-      'pretty' => true,
21
-      'cache' => 'var/cache/pug',
22
-      'basedir' => 'template/',
23
-      'upToDateCheck' => false,
24
-    ));
25
-
26
-    $link = $this->app->request->link();
27
-    $dir = $this->app->file->root();
28
-
29
-    //File Path
30
-    $file = str_replace('/', DS, $path);
31
-    $file = $dir . DS . 'template' . DS  . $file . '.pug';
32
-
33
-    //Css Path
34
-    $css = $this->app->file->css();
35
-    $css = str_replace($dir, $link, $css);
36
-    $css = str_replace('\\', '/', $css);
37
-
38
-    //Js Path
39
-    $js = $this->app->file->js();
40
-    $js = str_replace($dir, $link, $js);
41
-    $js = str_replace('\\', '/', $js);
42
-
43
-    $context += $this->app->config['website'];
44
-
45
-    $context += [
46
-      'css' => $css,
47
-      'js'  => $js
48
-    ];
49
-
50
-    return $pug->render($file, $context);
51
-  }
9
+	private $app;
10
+
11
+	public function __construct(Application $app)
12
+	{
13
+		$this->app = $app;
14
+	}
15
+
16
+	public function render($path, array $context)
17
+	{
18
+		$this->app->file->css();
19
+		$pug = new Pug(array(
20
+			'pretty' => true,
21
+			'cache' => 'var/cache/pug',
22
+			'basedir' => 'template/',
23
+			'upToDateCheck' => false,
24
+		));
25
+
26
+		$link = $this->app->request->link();
27
+		$dir = $this->app->file->root();
28
+
29
+		//File Path
30
+		$file = str_replace('/', DS, $path);
31
+		$file = $dir . DS . 'template' . DS  . $file . '.pug';
32
+
33
+		//Css Path
34
+		$css = $this->app->file->css();
35
+		$css = str_replace($dir, $link, $css);
36
+		$css = str_replace('\\', '/', $css);
37
+
38
+		//Js Path
39
+		$js = $this->app->file->js();
40
+		$js = str_replace($dir, $link, $js);
41
+		$js = str_replace('\\', '/', $js);
42
+
43
+		$context += $this->app->config['website'];
44
+
45
+		$context += [
46
+			'css' => $css,
47
+			'js'  => $js
48
+		];
49
+
50
+		return $pug->render($file, $context);
51
+	}
52 52
 }
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
Core/System/Http/UploadeFile.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
   public function exists()
64 64
   {
65
-    return ! empty($this->file);
65
+    return !empty($this->file);
66 66
   }
67 67
 
68 68
   public function getFileName()
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
     $newName .= '.' . $this->extension;
108 108
 
109
-    if (! is_dir($target)) mkdir($target, 0777, true);
109
+    if (!is_dir($target)) mkdir($target, 0777, true);
110 110
 
111 111
     $filePath = $target . $newName;
112 112
 
Please login to merge, or discard this patch.
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -6,115 +6,115 @@
 block discarded – undo
6 6
 
7 7
 class UploadeFile
8 8
 {
9
-  private $app;
9
+	private $app;
10 10
 
11
-  private $file = [];
11
+	private $file = [];
12 12
 
13
-  private $fileName;
13
+	private $fileName;
14 14
 
15
-  private $nameOnly;
15
+	private $nameOnly;
16 16
 
17
-  private $extension;
17
+	private $extension;
18 18
 
19
-  private $minetype;
19
+	private $minetype;
20 20
 
21
-  private $tempFile;
21
+	private $tempFile;
22 22
 
23
-  private $size;
23
+	private $size;
24 24
 
25
-  private $error;
25
+	private $error;
26 26
 
27
-  private const AllOW_EXTENSION = ['png', 'jpg', 'jpeg', 'gif', 'webp'];
27
+	private const AllOW_EXTENSION = ['png', 'jpg', 'jpeg', 'gif', 'webp'];
28 28
 
29
-  public function __construct(Application $app, $input)
30
-  {
31
-    $this->app = $app;
29
+	public function __construct(Application $app, $input)
30
+	{
31
+		$this->app = $app;
32 32
 
33
-    $this->getFileInfo($input);
34
-  }
33
+		$this->getFileInfo($input);
34
+	}
35 35
 
36
-  private function getFileInfo($input)
37
-  {
38
-    if (empty($_FILES[$input])) return;
36
+	private function getFileInfo($input)
37
+	{
38
+		if (empty($_FILES[$input])) return;
39 39
 
40
-    $file = $_FILES[$input];
40
+		$file = $_FILES[$input];
41 41
 
42
-    $this->error = $file['error'];
42
+		$this->error = $file['error'];
43 43
 
44
-    if ($this->error != UPLOAD_ERR_OK) return;
44
+		if ($this->error != UPLOAD_ERR_OK) return;
45 45
 
46
-    $this->file = $file;
46
+		$this->file = $file;
47 47
 
48
-    $this->fileName = $this->file['name'];
48
+		$this->fileName = $this->file['name'];
49 49
 
50
-    $this->minetype = $this->file['type'];
50
+		$this->minetype = $this->file['type'];
51 51
 
52
-    $this->size = $this->file['size'];
52
+		$this->size = $this->file['size'];
53 53
 
54
-    $this->tempFile = $this->file['tmp_name'];
54
+		$this->tempFile = $this->file['tmp_name'];
55 55
 
56
-    $fileInfo = pathinfo($this->fileName);
56
+		$fileInfo = pathinfo($this->fileName);
57 57
 
58
-    $this->nameOnly = $fileInfo['filename'];
58
+		$this->nameOnly = $fileInfo['filename'];
59 59
 
60
-    $this->extension = $fileInfo['extension'];
61
-  }
60
+		$this->extension = $fileInfo['extension'];
61
+	}
62 62
 
63
-  public function exists()
64
-  {
65
-    return ! empty($this->file);
66
-  }
63
+	public function exists()
64
+	{
65
+		return ! empty($this->file);
66
+	}
67 67
 
68
-  public function getFileName()
69
-  {
70
-    return $this->fileName;
71
-  }
68
+	public function getFileName()
69
+	{
70
+		return $this->fileName;
71
+	}
72 72
 
73
-  public function getNameOnly()
74
-  {
75
-    return $this->nameOnly;
76
-  }
73
+	public function getNameOnly()
74
+	{
75
+		return $this->nameOnly;
76
+	}
77 77
 
78
-  public function getExtension()
79
-  {
80
-    return $this->extension;
81
-  }
78
+	public function getExtension()
79
+	{
80
+		return $this->extension;
81
+	}
82 82
 
83
-  public function getMinetype()
84
-  {
85
-    return $this->minetype;
86
-  }
83
+	public function getMinetype()
84
+	{
85
+		return $this->minetype;
86
+	}
87 87
 
88
-  public function getSize()
89
-  {
90
-    return $this->size;
91
-  }
88
+	public function getSize()
89
+	{
90
+		return $this->size;
91
+	}
92 92
 
93
-  public function getTempFile()
94
-  {
95
-    return $this->tempFile;
96
-  }
93
+	public function getTempFile()
94
+	{
95
+		return $this->tempFile;
96
+	}
97 97
 
98
-  public function isImage()
99
-  {
100
-    return strpos($this->minetype, 'image/') === 0 && in_array($this->extension, self::AllOW_EXTENSION);
101
-  }
98
+	public function isImage()
99
+	{
100
+		return strpos($this->minetype, 'image/') === 0 && in_array($this->extension, self::AllOW_EXTENSION);
101
+	}
102 102
 
103
-  public function moveTo($target, $newName = null)
104
-  {
105
-    $newName = $newName ?: sha1(rand()) . sha1(rand());
103
+	public function moveTo($target, $newName = null)
104
+	{
105
+		$newName = $newName ?: sha1(rand()) . sha1(rand());
106 106
 
107
-    $newName .= '.' . $this->extension;
107
+		$newName .= '.' . $this->extension;
108 108
 
109
-    if (! is_dir($target)) mkdir($target, 0777, true);
109
+		if (! is_dir($target)) mkdir($target, 0777, true);
110 110
 
111
-    $filePath = $target . $newName;
111
+		$filePath = $target . $newName;
112 112
 
113
-    $filePath  = rtrim($filePath, '/');
114
-    $filePath  = ltrim($filePath, '/');
113
+		$filePath  = rtrim($filePath, '/');
114
+		$filePath  = ltrim($filePath, '/');
115 115
 
116
-    $uploade = move_uploaded_file($this->tempFile, $filePath);
116
+		$uploade = move_uploaded_file($this->tempFile, $filePath);
117 117
 
118
-    return $uploade;
119
-  }
118
+		return $uploade;
119
+	}
120 120
 }
121 121
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,13 +35,17 @@  discard block
 block discarded – undo
35 35
 
36 36
   private function getFileInfo($input)
37 37
   {
38
-    if (empty($_FILES[$input])) return;
38
+    if (empty($_FILES[$input])) {
39
+    	return;
40
+    }
39 41
 
40 42
     $file = $_FILES[$input];
41 43
 
42 44
     $this->error = $file['error'];
43 45
 
44
-    if ($this->error != UPLOAD_ERR_OK) return;
46
+    if ($this->error != UPLOAD_ERR_OK) {
47
+    	return;
48
+    }
45 49
 
46 50
     $this->file = $file;
47 51
 
@@ -106,7 +110,9 @@  discard block
 block discarded – undo
106 110
 
107 111
     $newName .= '.' . $this->extension;
108 112
 
109
-    if (! is_dir($target)) mkdir($target, 0777, true);
113
+    if (! is_dir($target)) {
114
+    	mkdir($target, 0777, true);
115
+    }
110 116
 
111 117
     $filePath = $target . $newName;
112 118
 
Please login to merge, or discard this patch.
Core/System/Validation.php 3 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
 
25 25
   public function require($input = null, $msg = null)
26 26
   {
27
-    if (! $this->input) $this->input = $input;
27
+    if (!$this->input) $this->input = $input;
28 28
 
29 29
     $value = $this->value($this->input);
30 30
 
31
-    if (! $value) {
31
+    if (!$value) {
32 32
 
33 33
         $msg = $msg ?: 'This input is required';
34 34
 
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 
40 40
   public function email($input = null, $msg = null)
41 41
   {
42
-    if (! $this->input) $this->input = $input;
42
+    if (!$this->input) $this->input = $input;
43 43
 
44 44
     $value = $this->value($this->input);
45 45
 
46
-    if (! filter_var($value, FILTER_VALIDATE_EMAIL)) {
46
+    if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
47 47
 
48 48
       $msg = $msg ?: sprintf('%s is not valid Email', ucfirst($this->input));
49 49
 
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 
55 55
   public function number($input = null, $msg = null)
56 56
   {
57
-    if (! $this->input) $this->input = $input;
57
+    if (!$this->input) $this->input = $input;
58 58
 
59 59
     $value = $this->value($this->input);
60 60
 
61 61
     if ($value) {
62 62
 
63
-      if (! is_numeric($value)) {
63
+      if (!is_numeric($value)) {
64 64
 
65 65
         $msg = $msg ?: 'the Input must be number';
66 66
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
   public function text($input = null, $msg = null)
74 74
   {
75
-    if (! $this->input) $this->input = $input;
75
+    if (!$this->input) $this->input = $input;
76 76
 
77 77
     $value = $this->value($this->input);
78 78
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
     $valueConfirm = $this->value($input);
128 128
 
129
-    if ($valuePassword && $valueConfirm ) {
129
+    if ($valuePassword && $valueConfirm) {
130 130
 
131 131
       if ($valuePassword !== $valueConfirm) {
132 132
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
   public function fails()
200 200
   {
201
-    return ! empty($this->errors);
201
+    return !empty($this->errors);
202 202
   }
203 203
 
204 204
   public function getMsgs()
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
   public function addError($input, $msg)
215 215
   {
216
-    if (! $this->checkError($input)) {
216
+    if (!$this->checkError($input)) {
217 217
 
218 218
       $this->errors[$input] = $msg;
219 219
     }
Please login to merge, or discard this patch.
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -4,211 +4,211 @@
 block discarded – undo
4 4
 
5 5
 class Validation
6 6
 {
7
-  private $app;
7
+	private $app;
8 8
 
9
-  private $input;
9
+	private $input;
10 10
 
11
-  private $errors = [];
11
+	private $errors = [];
12 12
 
13
-  public function __construct(Application $app)
14
-  {
15
-    $this->app = $app;
16
-  }
13
+	public function __construct(Application $app)
14
+	{
15
+		$this->app = $app;
16
+	}
17 17
 
18
-  public function input($input)
19
-  {
20
-    $this->input = $input;
18
+	public function input($input)
19
+	{
20
+		$this->input = $input;
21 21
 
22
-    return $this;
23
-  }
22
+		return $this;
23
+	}
24 24
 
25
-  public function require($input = null, $msg = null)
26
-  {
27
-    if (! $this->input) $this->input = $input;
25
+	public function require($input = null, $msg = null)
26
+	{
27
+		if (! $this->input) $this->input = $input;
28 28
 
29
-    $value = $this->value($this->input);
29
+		$value = $this->value($this->input);
30 30
 
31
-    if (! $value) {
31
+		if (! $value) {
32 32
 
33
-        $msg = $msg ?: 'This input is required';
33
+				$msg = $msg ?: 'This input is required';
34 34
 
35
-        $this->addError($this->input, $msg);
36
-    }
37
-    return $this;
38
-  }
35
+				$this->addError($this->input, $msg);
36
+		}
37
+		return $this;
38
+	}
39 39
 
40
-  public function email($input = null, $msg = null)
41
-  {
42
-    if (! $this->input) $this->input = $input;
40
+	public function email($input = null, $msg = null)
41
+	{
42
+		if (! $this->input) $this->input = $input;
43 43
 
44
-    $value = $this->value($this->input);
44
+		$value = $this->value($this->input);
45 45
 
46
-    if (! filter_var($value, FILTER_VALIDATE_EMAIL)) {
46
+		if (! filter_var($value, FILTER_VALIDATE_EMAIL)) {
47 47
 
48
-      $msg = $msg ?: sprintf('%s is not valid Email', ucfirst($this->input));
48
+			$msg = $msg ?: sprintf('%s is not valid Email', ucfirst($this->input));
49 49
 
50
-      $this->addError($this->input, $msg);
51
-    }
52
-    return $this;
53
-  }
50
+			$this->addError($this->input, $msg);
51
+		}
52
+		return $this;
53
+	}
54 54
 
55
-  public function number($input = null, $msg = null)
56
-  {
57
-    if (! $this->input) $this->input = $input;
55
+	public function number($input = null, $msg = null)
56
+	{
57
+		if (! $this->input) $this->input = $input;
58 58
 
59
-    $value = $this->value($this->input);
59
+		$value = $this->value($this->input);
60 60
 
61
-    if ($value) {
61
+		if ($value) {
62 62
 
63
-      if (! is_numeric($value)) {
63
+			if (! is_numeric($value)) {
64 64
 
65
-        $msg = $msg ?: 'the Input must be number';
65
+				$msg = $msg ?: 'the Input must be number';
66 66
 
67
-        $this->addError($this->input, $msg);
68
-      }
69
-    }
70
-    return $this;
71
-  }
67
+				$this->addError($this->input, $msg);
68
+			}
69
+		}
70
+		return $this;
71
+	}
72 72
 
73
-  public function text($input = null, $msg = null)
74
-  {
75
-    if (! $this->input) $this->input = $input;
73
+	public function text($input = null, $msg = null)
74
+	{
75
+		if (! $this->input) $this->input = $input;
76 76
 
77
-    $value = $this->value($this->input);
77
+		$value = $this->value($this->input);
78 78
 
79
-    if ($value) {
79
+		if ($value) {
80 80
 
81
-      if (is_numeric($value)) {
81
+			if (is_numeric($value)) {
82 82
 
83
-        $msg = $msg ?: 'the Input must be Text';
83
+				$msg = $msg ?: 'the Input must be Text';
84 84
 
85
-        $this->addError($this->input, $msg);
86
-      }
87
-    }
88
-    return $this;
89
-  }
85
+				$this->addError($this->input, $msg);
86
+			}
87
+		}
88
+		return $this;
89
+	}
90 90
 
91
-  public function minLen($length, $msg = null)
92
-  {
93
-    $value = $this->value($this->input);
91
+	public function minLen($length, $msg = null)
92
+	{
93
+		$value = $this->value($this->input);
94 94
 
95
-    if ($value) {
95
+		if ($value) {
96 96
 
97
-      if (strlen($value) < $length) {
97
+			if (strlen($value) < $length) {
98 98
 
99
-        $msg = $msg ?: 'This input must be at least ' . $length;
99
+				$msg = $msg ?: 'This input must be at least ' . $length;
100 100
 
101
-        $this->addError($this->input, $msg);
102
-      }
103
-    }
104
-    return $this;
105
-  }
101
+				$this->addError($this->input, $msg);
102
+			}
103
+		}
104
+		return $this;
105
+	}
106 106
 
107
-  public function maxLen($length, $msg = null)
108
-  {
109
-    $value = $this->value($this->input);
107
+	public function maxLen($length, $msg = null)
108
+	{
109
+		$value = $this->value($this->input);
110 110
 
111
-    if ($value) {
111
+		if ($value) {
112 112
 
113
-      if (strlen($value) > $length) {
113
+			if (strlen($value) > $length) {
114 114
 
115
-        $msg = $msg ?: 'This must be ' . $length . ' or fewer';
115
+				$msg = $msg ?: 'This must be ' . $length . ' or fewer';
116 116
 
117
-        $this->addError($this->input, $msg);
118
-      }
119
-    }
120
-    return $this;
121
-  }
117
+				$this->addError($this->input, $msg);
118
+			}
119
+		}
120
+		return $this;
121
+	}
122 122
 
123
-  public function match($input, $msg = null)
124
-  {
125
-    $valuePassword = $this->value($this->input);
123
+	public function match($input, $msg = null)
124
+	{
125
+		$valuePassword = $this->value($this->input);
126 126
 
127
-    $valueConfirm = $this->value($input);
127
+		$valueConfirm = $this->value($input);
128 128
 
129
-    if ($valuePassword && $valueConfirm ) {
129
+		if ($valuePassword && $valueConfirm ) {
130 130
 
131
-      if ($valuePassword !== $valueConfirm) {
131
+			if ($valuePassword !== $valueConfirm) {
132 132
 
133
-        $msg = $msg ?: 'Passwords does not match';
133
+				$msg = $msg ?: 'Passwords does not match';
134 134
 
135
-        $this->addError('match', $msg);
136
-      }
137
-    }
138
-    return $this;
139
-  }
135
+				$this->addError('match', $msg);
136
+			}
137
+		}
138
+		return $this;
139
+	}
140 140
 
141
-  public function unique(array $data, $msg = null)
142
-  {
143
-    $value = $this->value($this->input);
141
+	public function unique(array $data, $msg = null)
142
+	{
143
+		$value = $this->value($this->input);
144 144
 
145
-    $table = null;
146
-    $column = null;
145
+		$table = null;
146
+		$column = null;
147 147
 
148
-    $id = null;
149
-    $userId = null;
148
+		$id = null;
149
+		$userId = null;
150 150
 
151
-    if (count($data) == 2) {
151
+		if (count($data) == 2) {
152 152
 
153
-      list($table, $column) = $data;
153
+			list($table, $column) = $data;
154 154
 
155
-    } elseif (count($data) == 4) {
155
+		} elseif (count($data) == 4) {
156 156
 
157
-      list($table, $column, $id, $userId) = $data;
158
-    }
157
+			list($table, $column, $id, $userId) = $data;
158
+		}
159 159
 
160
-    $sql = $userId ? $column . ' = ? AND ' . $id . ' != ? ' : $column . ' = ?';
160
+		$sql = $userId ? $column . ' = ? AND ' . $id . ' != ? ' : $column . ' = ?';
161 161
 
162
-    $valueSql = $userId ? [$value, $userId] : $value;
162
+		$valueSql = $userId ? [$value, $userId] : $value;
163 163
 
164
-    $result = $this->app->db->select($column)->from($table)->where($sql, $valueSql)->fetch();
164
+		$result = $this->app->db->select($column)->from($table)->where($sql, $valueSql)->fetch();
165 165
 
166
-    if ($result) {
166
+		if ($result) {
167 167
 
168
-      $msg = $msg ?: sprintf('%s is already exist', ucfirst($this->input));
168
+			$msg = $msg ?: sprintf('%s is already exist', ucfirst($this->input));
169 169
 
170
-      $this->addError($this->input, $msg);
171
-    }
172
-    return $this;
173
-  }
170
+			$this->addError($this->input, $msg);
171
+		}
172
+		return $this;
173
+	}
174 174
 
175
-  public function message($msg = null)
176
-  {
177
-    $this->errors[] = $msg;
175
+	public function message($msg = null)
176
+	{
177
+		$this->errors[] = $msg;
178 178
 
179
-    return $this;
180
-  }
179
+		return $this;
180
+	}
181 181
 
182
-  public function passes()
183
-  {
184
-    return empty($this->errors);
185
-  }
182
+	public function passes()
183
+	{
184
+		return empty($this->errors);
185
+	}
186 186
 
187
-  public function fails()
188
-  {
189
-    return ! empty($this->errors);
190
-  }
187
+	public function fails()
188
+	{
189
+		return ! empty($this->errors);
190
+	}
191 191
 
192
-  public function getMsgs()
193
-  {
194
-    return $this->errors;
195
-  }
192
+	public function getMsgs()
193
+	{
194
+		return $this->errors;
195
+	}
196 196
 
197
-  private function value($input)
198
-  {
199
-    return $this->app->request->post($input);
200
-  }
197
+	private function value($input)
198
+	{
199
+		return $this->app->request->post($input);
200
+	}
201 201
 
202
-  public function addError($input, $msg)
203
-  {
204
-    if (! $this->checkError($input)) {
202
+	public function addError($input, $msg)
203
+	{
204
+		if (! $this->checkError($input)) {
205 205
 
206
-      $this->errors[$input] = $msg;
207
-    }
208
-  }
206
+			$this->errors[$input] = $msg;
207
+		}
208
+	}
209 209
 
210
-  private function checkError($input)
211
-  {
212
-    return array_key_exists($input, $this->errors);
213
-  }
210
+	private function checkError($input)
211
+	{
212
+		return array_key_exists($input, $this->errors);
213
+	}
214 214
 }
215 215
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 
25 25
   public function require($input = null, $msg = null)
26 26
   {
27
-    if (! $this->input) $this->input = $input;
27
+    if (! $this->input) {
28
+    	$this->input = $input;
29
+    }
28 30
 
29 31
     $value = $this->value($this->input);
30 32
 
@@ -39,7 +41,9 @@  discard block
 block discarded – undo
39 41
 
40 42
   public function email($input = null, $msg = null)
41 43
   {
42
-    if (! $this->input) $this->input = $input;
44
+    if (! $this->input) {
45
+    	$this->input = $input;
46
+    }
43 47
 
44 48
     $value = $this->value($this->input);
45 49
 
@@ -54,7 +58,9 @@  discard block
 block discarded – undo
54 58
 
55 59
   public function number($input = null, $msg = null)
56 60
   {
57
-    if (! $this->input) $this->input = $input;
61
+    if (! $this->input) {
62
+    	$this->input = $input;
63
+    }
58 64
 
59 65
     $value = $this->value($this->input);
60 66
 
@@ -72,7 +78,9 @@  discard block
 block discarded – undo
72 78
 
73 79
   public function text($input = null, $msg = null)
74 80
   {
75
-    if (! $this->input) $this->input = $input;
81
+    if (! $this->input) {
82
+    	$this->input = $input;
83
+    }
76 84
 
77 85
     $value = $this->value($this->input);
78 86
 
Please login to merge, or discard this patch.
Core/helpers.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 use System\Application;
4 4
 
5
-if (! function_exists('pre')) {
5
+if (!function_exists('pre')) {
6 6
   function pre($var) {
7 7
     echo '<pre>';
8 8
     print_r($var);
@@ -10,28 +10,28 @@  discard block
 block discarded – undo
10 10
   }
11 11
 }
12 12
 
13
-if (! function_exists('array_get')) {
13
+if (!function_exists('array_get')) {
14 14
   function array_get($array, $key, $default = null)
15 15
   {
16 16
     return $array[$key] ?: $default;
17 17
   }
18 18
 }
19 19
 
20
-if (! function_exists('app')) {
20
+if (!function_exists('app')) {
21 21
   function app()
22 22
   {
23 23
     return Application::getInstance();
24 24
   }
25 25
 }
26 26
 
27
-if (! function_exists('_e')) {
27
+if (!function_exists('_e')) {
28 28
   function _e($value)
29 29
   {
30 30
     return htmlspecialchars($value);
31 31
   }
32 32
 }
33 33
 
34
-if (! function_exists('getLastIndex')) {
34
+if (!function_exists('getLastIndex')) {
35 35
   function getLastIndex($index)
36 36
   {
37 37
     $array = explode('\\', $index);
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
   }
40 40
 }
41 41
 
42
-if (! function_exists('url')) {
42
+if (!function_exists('url')) {
43 43
   function url($path) {
44 44
     $app = Application::getInstance();
45 45
     return $app->url->link($path);
46 46
   }
47 47
 }
48 48
 
49
-if (! function_exists('assets')) {
49
+if (!function_exists('assets')) {
50 50
   function assets($path)
51 51
   {
52 52
     $app = Application::getInstance();
@@ -54,24 +54,24 @@  discard block
 block discarded – undo
54 54
   }
55 55
 }
56 56
 
57
-if (! function_exists('remove_space')) {
57
+if (!function_exists('remove_space')) {
58 58
   function remove_space($str) {
59 59
     return str_replace(' ', '-', $str);
60 60
   }
61 61
 }
62 62
 
63
-if (! function_exists('remove_dash')) {
63
+if (!function_exists('remove_dash')) {
64 64
   function remove_dash($str) {
65 65
     return str_replace('-', ' ', $str);
66 66
   }
67 67
 }
68 68
 
69
-if (! function_exists('clean_name_url')) {
69
+if (!function_exists('clean_name_url')) {
70 70
     function clean_name_url($class = null) {
71 71
 
72 72
       $app = Application::getInstance();
73 73
 
74
-      if (! $class) {
74
+      if (!$class) {
75 75
 
76 76
         $class = debug_backtrace()[1]['class'];
77 77
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
         $class = strtolower($class);
85 85
 
86
-        $class = '/' . $class .  '/';
86
+        $class = '/' . $class . '/';
87 87
       }
88 88
 
89 89
       $url = $app->request->url();
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
   }
97 97
 }
98 98
 
99
-if (! function_exists('text_char_limit')) {
99
+if (!function_exists('text_char_limit')) {
100 100
   function text_char_limit($text, $limit) {
101 101
     if (strlen($text) > $limit) {
102 102
       return substr($text, 0, $limit) . '...';
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
   }
105 105
 }
106 106
 
107
-if (! function_exists('array_equal')) {
107
+if (!function_exists('array_equal')) {
108 108
   function array_equal($a, $b) {
109 109
     return (
110 110
       is_array($a)
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
   }
116 116
 }
117 117
 
118
-if (! function_exists('redirect_after')) {
118
+if (!function_exists('redirect_after')) {
119 119
   function redirect_after($num) {
120 120
     $app = Application::getInstance();
121 121
     $app->url->redirectTo('/', $num);
Please login to merge, or discard this patch.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -3,121 +3,121 @@
 block discarded – undo
3 3
 use System\Application;
4 4
 
5 5
 if (! function_exists('pre')) {
6
-  function pre($var) {
7
-    echo '<pre>';
8
-    print_r($var);
9
-    echo '</pre>';
10
-  }
6
+	function pre($var) {
7
+		echo '<pre>';
8
+		print_r($var);
9
+		echo '</pre>';
10
+	}
11 11
 }
12 12
 
13 13
 if (! function_exists('array_get')) {
14
-  function array_get($array, $key, $default = null)
15
-  {
16
-    return $array[$key] ?: $default;
17
-  }
14
+	function array_get($array, $key, $default = null)
15
+	{
16
+		return $array[$key] ?: $default;
17
+	}
18 18
 }
19 19
 
20 20
 if (! function_exists('app')) {
21
-  function app()
22
-  {
23
-    return Application::getInstance();
24
-  }
21
+	function app()
22
+	{
23
+		return Application::getInstance();
24
+	}
25 25
 }
26 26
 
27 27
 if (! function_exists('_e')) {
28
-  function _e($value)
29
-  {
30
-    return htmlspecialchars($value);
31
-  }
28
+	function _e($value)
29
+	{
30
+		return htmlspecialchars($value);
31
+	}
32 32
 }
33 33
 
34 34
 if (! function_exists('getLastIndex')) {
35
-  function getLastIndex($index)
36
-  {
37
-    $array = explode('\\', $index);
38
-    return end($array);
39
-  }
35
+	function getLastIndex($index)
36
+	{
37
+		$array = explode('\\', $index);
38
+		return end($array);
39
+	}
40 40
 }
41 41
 
42 42
 if (! function_exists('url')) {
43
-  function url($path) {
44
-    $app = Application::getInstance();
45
-    return $app->url->link($path);
46
-  }
43
+	function url($path) {
44
+		$app = Application::getInstance();
45
+		return $app->url->link($path);
46
+	}
47 47
 }
48 48
 
49 49
 if (! function_exists('assets')) {
50
-  function assets($path)
51
-  {
52
-    $app = Application::getInstance();
53
-    return $app->url->link('public' . DS . $path);
54
-  }
50
+	function assets($path)
51
+	{
52
+		$app = Application::getInstance();
53
+		return $app->url->link('public' . DS . $path);
54
+	}
55 55
 }
56 56
 
57 57
 if (! function_exists('remove_space')) {
58
-  function remove_space($str) {
59
-    return str_replace(' ', '-', $str);
60
-  }
58
+	function remove_space($str) {
59
+		return str_replace(' ', '-', $str);
60
+	}
61 61
 }
62 62
 
63 63
 if (! function_exists('remove_dash')) {
64
-  function remove_dash($str) {
65
-    return str_replace('-', ' ', $str);
66
-  }
64
+	function remove_dash($str) {
65
+		return str_replace('-', ' ', $str);
66
+	}
67 67
 }
68 68
 
69 69
 if (! function_exists('clean_name_url')) {
70
-    function clean_name_url($class = null) {
70
+		function clean_name_url($class = null) {
71 71
 
72
-      $app = Application::getInstance();
72
+			$app = Application::getInstance();
73 73
 
74
-      if (! $class) {
74
+			if (! $class) {
75 75
 
76
-        $class = debug_backtrace()[1]['class'];
76
+				$class = debug_backtrace()[1]['class'];
77 77
 
78
-        $clases = explode('\\', $class);
78
+				$clases = explode('\\', $class);
79 79
 
80
-        $class = end($clases);
80
+				$class = end($clases);
81 81
 
82
-        $class = str_replace('Controller', '', $class);
82
+				$class = str_replace('Controller', '', $class);
83 83
 
84
-        $class = strtolower($class);
84
+				$class = strtolower($class);
85 85
 
86
-        $class = '/' . $class .  '/';
87
-      }
86
+				$class = '/' . $class .  '/';
87
+			}
88 88
 
89
-      $url = $app->request->url();
89
+			$url = $app->request->url();
90 90
 
91
-      $name = str_replace($class, '', $url);
91
+			$name = str_replace($class, '', $url);
92 92
 
93
-      $name = remove_dash($name);
93
+			$name = remove_dash($name);
94 94
 
95
-      return $name;
96
-  }
95
+			return $name;
96
+	}
97 97
 }
98 98
 
99 99
 if (! function_exists('text_char_limit')) {
100
-  function text_char_limit($text, $limit) {
101
-    if (strlen($text) > $limit) {
102
-      return substr($text, 0, $limit) . '...';
103
-    }
104
-  }
100
+	function text_char_limit($text, $limit) {
101
+		if (strlen($text) > $limit) {
102
+			return substr($text, 0, $limit) . '...';
103
+		}
104
+	}
105 105
 }
106 106
 
107 107
 if (! function_exists('array_equal')) {
108
-  function array_equal($a, $b) {
109
-    return (
110
-      is_array($a)
111
-      && is_array($b)
112
-      && count($a) == count($b)
113
-      && array_diff($a, $b) === array_diff($b, $a)
114
-    );
115
-  }
108
+	function array_equal($a, $b) {
109
+		return (
110
+			is_array($a)
111
+			&& is_array($b)
112
+			&& count($a) == count($b)
113
+			&& array_diff($a, $b) === array_diff($b, $a)
114
+		);
115
+	}
116 116
 }
117 117
 
118 118
 if (! function_exists('redirect_after')) {
119
-  function redirect_after($num) {
120
-    $app = Application::getInstance();
121
-    $app->url->redirectTo('/', $num);
122
-  }
119
+	function redirect_after($num) {
120
+		$app = Application::getInstance();
121
+		$app->url->redirectTo('/', $num);
122
+	}
123 123
 }
124 124
\ No newline at end of file
Please login to merge, or discard this patch.