Passed
Push — master ( bb463c...47732f )
by refat
04:00
created
Core/System/PugView.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,21 +6,21 @@  discard block
 block discarded – undo
6 6
 
7 7
 class PugView
8 8
 {
9
-  private $app;
9
+    private $app;
10 10
 
11
-  public function __construct(Application $app)
12
-  {
11
+    public function __construct(Application $app)
12
+    {
13 13
     $this->app = $app;
14
-  }
14
+    }
15 15
 
16
-  public function render($path, array $context)
17
-  {
16
+    public function render($path, array $context)
17
+    {
18 18
     $this->app->file->css();
19 19
     $pug = new Pug(array(
20
-      'pretty' => true,
21
-      'cache' => 'var/cache/pug',
22
-      'basedir' => 'template/',
23
-      'upToDateCheck' => false,
20
+        'pretty' => true,
21
+        'cache' => 'var/cache/pug',
22
+        'basedir' => 'template/',
23
+        'upToDateCheck' => false,
24 24
     ));
25 25
 
26 26
     $link = $this->app->request->link();
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
     $context += $this->app->config['website'];
44 44
 
45 45
     $context += [
46
-      'css' => $css,
47
-      'js'  => $js
46
+        'css' => $css,
47
+        'js'  => $js
48 48
     ];
49 49
 
50 50
     return $pug->render($file, $context);
51
-  }
51
+    }
52 52
 }
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
Core/System/File.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@  discard block
 block discarded – undo
6 6
 
7 7
 class File
8 8
 {
9
-  const DS = DIRECTORY_SEPARATOR;
9
+    const DS = DIRECTORY_SEPARATOR;
10 10
 
11
-  private $root;
11
+    private $root;
12 12
 
13
-  public function __construct($root)
14
-  {
13
+    public function __construct($root)
14
+    {
15 15
     $this->root = $root;
16
-  }
16
+    }
17 17
 
18
-  public function root()
19
-  {
18
+    public function root()
19
+    {
20 20
     return $this->root;
21
-  }
21
+    }
22 22
 
23
-  public function exists($file)
24
-  {
23
+    public function exists($file)
24
+    {
25 25
     return file_exists($file);
26
-  }
26
+    }
27 27
 
28
-  public function call($file)
29
-  {
28
+    public function call($file)
29
+    {
30 30
     if ($this->exists($file)) {
31 31
 
32 32
     return require $file;
@@ -35,30 +35,30 @@  discard block
 block discarded – undo
35 35
 
36 36
     throw new Exception("$file is not found");
37 37
     }
38
-  }
38
+    }
39 39
 
40
-  public function to($path, $ext = null)
41
-  {
40
+    public function to($path, $ext = null)
41
+    {
42 42
     return $this->root . static::DS . str_replace('/', static::DS, $path . $ext);
43
-  }
43
+    }
44 44
 
45
-  public function toPublic($target = null)
46
-  {
45
+    public function toPublic($target = null)
46
+    {
47 47
     return $this->to('public/' . $target);
48
-  }
48
+    }
49 49
 
50
-  public function images()
51
-  {
50
+    public function images()
51
+    {
52 52
     return $this->toPublic('images');
53
-  }
53
+    }
54 54
 
55
-  public function js()
56
-  {
55
+    public function js()
56
+    {
57 57
     return $this->toPublic('js');
58
-  }
58
+    }
59 59
 
60
-  public function css()
61
-  {
60
+    public function css()
61
+    {
62 62
     return $this->toPublic('css');
63
-  }
63
+    }
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
Core/System/Session.php 1 patch
Indentation   +29 added lines, -29 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;
7
+    private $app;
8 8
 
9
-  public function __construct(Application $app)
10
-  {
9
+    public function __construct(Application $app)
10
+    {
11 11
     $this->app = $app;
12
-  }
12
+    }
13 13
 
14
-  public function start()
15
-  {
14
+    public function start()
15
+    {
16 16
     ini_set('session.use_only_cookies', 1);
17 17
 
18 18
     if (! session_id()) {
19
-      session_start();
19
+        session_start();
20
+    }
20 21
     }
21
-  }
22 22
 
23
-  public function set($key, $value)
24
-  {
23
+    public function set($key, $value)
24
+    {
25 25
     $_SESSION[$key] = $value;
26
-  }
26
+    }
27 27
 
28
-  public function get($key, $default = null)
29
-  {
28
+    public function get($key, $default = null)
29
+    {
30 30
     return array_get($_SESSION, $key, $default);
31
-  }
31
+    }
32 32
 
33
-  public function pull($key)
34
-  {
33
+    public function pull($key)
34
+    {
35 35
     $value = $this->get($key);
36 36
 
37 37
     $this->remove($key);
38 38
 
39 39
     return $value;
40
-  }
40
+    }
41 41
 
42
-  public function has($key)
43
-  {
42
+    public function has($key)
43
+    {
44 44
     return isset($_SESSION[$key]);
45
-  }
45
+    }
46 46
 
47
-  public function all()
48
-  {
47
+    public function all()
48
+    {
49 49
     return $_SESSION;
50
-  }
50
+    }
51 51
 
52
-  public function remove($key)
53
-  {
52
+    public function remove($key)
53
+    {
54 54
     unset($_SESSION[$key]);
55
-  }
55
+    }
56 56
 
57
-  public function destroy()
58
-  {
57
+    public function destroy()
58
+    {
59 59
     session_destroy();
60 60
 
61 61
     unset($_SESSION);
62
-  }
62
+    }
63 63
 }
64 64
\ No newline at end of file
Please login to merge, or discard this patch.
Core/System/Model.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -4,62 +4,62 @@  discard block
 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
-  {
11
+    public function __construct(Application $app)
12
+    {
13 13
     $this->app = $app;
14
-  }
14
+    }
15 15
 
16
-  public function __get($key)
17
-  {
16
+    public function __get($key)
17
+    {
18 18
     return $this->app->get($key);
19
-  }
19
+    }
20 20
 
21
-  public function __call($method, $args)
22
-  {
21
+    public function __call($method, $args)
22
+    {
23 23
     return call_user_func_array([$this->app->db, $method], $args);
24
-  }
24
+    }
25 25
 
26
-  public function all($limit = null)
27
-  {
26
+    public function all($limit = null)
27
+    {
28 28
     return $this->orderBy('id', 'DESC')->limit($limit)->fetchAll($this->table);
29
-  }
29
+    }
30 30
 
31
-  public function allEnable($limit = null)
32
-  {
31
+    public function allEnable($limit = null)
32
+    {
33 33
     return $this->orderBy('id', 'DESC')->where('enable = ?', 1)->limit($limit)->fetchAll($this->table);
34
-  }
34
+    }
35 35
 
36
-  public function get($value, $coulmn = 'id')
37
-  {
36
+    public function get($value, $coulmn = 'id')
37
+    {
38 38
     return $this->where($coulmn . ' = ?' , $value)->fetch($this->table);
39
-  }
39
+    }
40 40
 
41
-  public function getEnable($value, $coulmn = 'id')
42
-  {
41
+    public function getEnable($value, $coulmn = 'id')
42
+    {
43 43
     return $this->where($coulmn . ' = ? AND enable = ?' , [$value, 1])->fetch($this->table);
44
-  }
44
+    }
45 45
 
46
-  public function selectTable($coulmn)
47
-  {
46
+    public function selectTable($coulmn)
47
+    {
48 48
     return $this->select($coulmn)->fetchAll($this->table);
49
-  }
49
+    }
50 50
 
51
-  public function exists($value, $key = 'id')
52
-  {
51
+    public function exists($value, $key = 'id')
52
+    {
53 53
     return (bool) $this->select($key)->where($key .'=?' , $value)->fetch($this->table);
54
-  }
54
+    }
55 55
 
56
-  public function delete($id)
57
-  {
56
+    public function delete($id)
57
+    {
58 58
     return $this->where('id = ?' , $id)->delete($this->table);
59
-  }
59
+    }
60 60
 
61
-  public function hasOne($join, $id = null, $select = '*', $limit = null, $localId = null, $forginId = null)
62
-  {
61
+    public function hasOne($join, $id = null, $select = '*', $limit = null, $localId = null, $forginId = null)
62
+    {
63 63
     $join = rtrim($join, 'Model');
64 64
 
65 65
     $file = $this->app->file->to( 'App/Models/' . $join . 'Model', '.php');
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
     $join = $this->load->model($join)->table;
76 76
 
77 77
     return $this->db->select($select)->from($table)->join($join, $localId, $forginId)->where($table . '.id = ?', $id)->limit($limit)->fetch();
78
-  }
78
+    }
79 79
 
80
-  public function hasMany($join, $id = null, $select = '*', $limit = null, $localId = null, $forginId = null)
81
-  {
80
+    public function hasMany($join, $id = null, $select = '*', $limit = null, $localId = null, $forginId = null)
81
+    {
82 82
     $join = rtrim($join, 'Model');
83 83
 
84 84
     $file = $this->app->file->to( 'App/Models/' . $join . 'Model', '.php');
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
     $join = $this->load->model($join)->table;
95 95
 
96 96
     return $this->db->select($select)->from($table)->join($join, $localId, $forginId)->where($table . '.id = ?', $id)->limit($limit)->fetchAll();
97
-  }
97
+    }
98 98
 
99
-  public function join($join, $limit = null, $enable = null, $localId = null, $forginId = null)
100
-  {
99
+    public function join($join, $limit = null, $enable = null, $localId = null, $forginId = null)
100
+    {
101 101
     $join = rtrim($join, 'Model');
102 102
 
103 103
     $file = $this->app->file->to( 'App/Models/' . $join . 'Model', '.php');
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 
115 115
     if ($enable) {
116 116
 
117
-      return $this->db->select()->from($table)->join($join, $localId, $forginId)->where('enable = ?', 1)->limit($limit)->fetchAll();
117
+        return $this->db->select()->from($table)->join($join, $localId, $forginId)->where('enable = ?', 1)->limit($limit)->fetchAll();
118 118
     }
119 119
 
120 120
     return $this->db->select()->from($table)->join($join, $localId, $forginId)->limit($limit)->fetchAll();
121
-  }
121
+    }
122 122
 }
123 123
\ No newline at end of file
Please login to merge, or discard this patch.
Core/System/Route.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -6,70 +6,70 @@  discard block
 block discarded – undo
6 6
 
7 7
 class Route
8 8
 {
9
-  const NEXT = '_NEXT_';
9
+    const NEXT = '_NEXT_';
10 10
 
11
-  private $app;
11
+    private $app;
12 12
 
13
-  private $routes = [];
13
+    private $routes = [];
14 14
 
15
-  public $current = [];
15
+    public $current = [];
16 16
 
17
-  private $prefix;
17
+    private $prefix;
18 18
 
19
-  private $basController;
19
+    private $basController;
20 20
 
21
-  private $middlewareFrom;
21
+    private $middlewareFrom;
22 22
 
23
-  private $groupMiddleware = [];
23
+    private $groupMiddleware = [];
24 24
 
25
-  public function __construct(Application $app)
26
-  {
25
+    public function __construct(Application $app)
26
+    {
27 27
     $this->app = $app;
28
-  }
28
+    }
29 29
 
30
-  public function add($url, $action, $requestMethos = 'GET', $middleware = [])
31
-  {
30
+    public function add($url, $action, $requestMethos = 'GET', $middleware = [])
31
+    {
32 32
     if ($this->prefix) {
33 33
 
34
-      if ($this->prefix !== '/') {
34
+        if ($this->prefix !== '/') {
35 35
 
36 36
         $url = $this->prefix . $url;
37 37
 
38 38
         $url = rtrim($url, '/');
39
-      }
39
+        }
40 40
     }
41 41
 
42
-      if ($this->basController) $action = $this->basController . '/' . $action;
42
+        if ($this->basController) $action = $this->basController . '/' . $action;
43 43
 
44 44
     if ($this->groupMiddleware) {
45 45
 
46
-      if (is_array($middleware)) {
46
+        if (is_array($middleware)) {
47 47
 
48 48
         $middleware = array_merge($this->groupMiddleware[0], $middleware);
49 49
 
50
-      } else {
50
+        } else {
51 51
 
52 52
         array_push($this->groupMiddleware[0], $middleware);
53 53
 
54 54
         $middleware = $this->groupMiddleware[0];
55
-      }
55
+        }
56 56
     }
57 57
 
58 58
     $routes = [
59
-      'url'       => $url,
60
-      'pattern'   => $this->generatePattern($url),
61
-      'action'    => $this->getAction($action),
62
-      'method'    => $requestMethos,
63
-      'middleware' => $middleware
59
+        'url'       => $url,
60
+        'pattern'   => $this->generatePattern($url),
61
+        'action'    => $this->getAction($action),
62
+        'method'    => $requestMethos,
63
+        'middleware' => $middleware
64 64
     ];
65 65
 
66 66
     $this->routes[] = $routes;
67 67
 
68 68
     return $this;
69
-  }
69
+    }
70 70
 
71
-  public function group($groupOptions, callable $callback)
72
-  {
71
+    public function group($groupOptions, callable $callback)
72
+    {
73 73
     $prefix = $groupOptions['prefix'];
74 74
     $controller = $groupOptions['controller'];
75 75
     $middlewareFrom = array_shift($groupOptions['middleware']);
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
     $callback($this);
86 86
 
87 87
     return $this;
88
-  }
88
+    }
89 89
 
90
-  public function package($url, $controller)
91
-  {
90
+    public function package($url, $controller)
91
+    {
92 92
     $this->add("$url", "$controller");
93 93
     $this->add("$url/add", "$controller@add", "POST");
94 94
     $this->add("$url/submit", "$controller@submit", "POST");
@@ -97,19 +97,19 @@  discard block
 block discarded – undo
97 97
     $this->add("$url/delete/:id", "$controller@delete", "POST");
98 98
 
99 99
     return $this;
100
-  }
100
+    }
101 101
 
102
-  public function generatePattern($url)
103
-  {
102
+    public function generatePattern($url)
103
+    {
104 104
     $pattern = '#^';
105 105
     $pattern .= str_replace([':text', ':id'], ['([a-zA-Z0-9-]+)', '(\d+)'], $url);
106 106
     $pattern .= '$#';
107 107
 
108 108
     return $pattern;
109
-  }
109
+    }
110 110
 
111
-  public function getAction($action)
112
-  {
111
+    public function getAction($action)
112
+    {
113 113
     $action = str_replace('/', '\\', $action);
114 114
 
115 115
     $action = (strpos($action, '@') != 0) ? $action : $action . '@index';
@@ -117,49 +117,49 @@  discard block
 block discarded – undo
117 117
     $action = explode('@', $action);
118 118
 
119 119
     return $action;
120
-  }
120
+    }
121 121
 
122
-  public function getProperRoute()
123
-  {
122
+    public function getProperRoute()
123
+    {
124 124
     foreach($this->routes as $route) {
125 125
 
126 126
         if ($this->isMatching($route['pattern']) && $this->isMatchingRequestMethod($route['method'])) {
127 127
 
128
-          $this->current = $route;
128
+            $this->current = $route;
129 129
 
130
-          $output = '';
130
+            $output = '';
131 131
 
132
-          if ($route['middleware']) {
132
+            if ($route['middleware']) {
133 133
 
134 134
             if (is_array($route['middleware'])) {
135 135
 
136
-              foreach($route['middleware'] as $middleware) {
136
+                foreach($route['middleware'] as $middleware) {
137 137
 
138 138
                 $output = $this->middleware($middleware);
139 139
 
140 140
                 if ($output != '') break;
141
-              }
141
+                }
142 142
 
143 143
             } else {
144 144
 
145
-              $output = $this->middleware($route['middleware']);
145
+                $output = $this->middleware($route['middleware']);
146 146
 
147
-              if ($output != '') break;
147
+                if ($output != '') break;
148
+            }
148 149
             }
149
-          }
150 150
 
151 151
             if ($output == '') {
152 152
 
153
-              list($controller, $method) = $route['action'];
153
+                list($controller, $method) = $route['action'];
154 154
 
155
-              $arguments = $this->getArgumentsFor($route['pattern']);
155
+                $arguments = $this->getArgumentsFor($route['pattern']);
156 156
 
157
-              $output = (string) $this->app->load->action($controller, $method, $arguments);
157
+                $output = (string) $this->app->load->action($controller, $method, $arguments);
158 158
 
159
-              return $output;
159
+                return $output;
160 160
 
161 161
             } else {
162
-              break;
162
+                break;
163 163
             }
164 164
         }
165 165
     }
@@ -167,42 +167,42 @@  discard block
 block discarded – undo
167 167
     $output = (string) $this->app->load->action('notFound', 'index', []);
168 168
 
169 169
     return $output;
170
-  }
170
+    }
171 171
 
172
-  public function isMatching($pattern)
173
-  {
172
+    public function isMatching($pattern)
173
+    {
174 174
     $url = $this->app->request->url();
175 175
 
176 176
     return preg_match($pattern, $url);
177
-  }
177
+    }
178 178
 
179
-  private function isMatchingRequestMethod($method)
180
-  {
179
+    private function isMatchingRequestMethod($method)
180
+    {
181 181
     $methods = ['GET', 'POST'];
182 182
 
183 183
     if (($method == 'both') && in_array($this->app->request->method(), $methods)) return true;
184 184
 
185 185
     if (is_array($method)) {
186 186
 
187
-      if (count($method) == 1) {
187
+        if (count($method) == 1) {
188 188
 
189 189
         $method = $method[0];
190 190
 
191
-      } else if (count($method) == 2) {
191
+        } else if (count($method) == 2) {
192 192
 
193 193
         if (in_array($method[0], $methods) && in_array($method[1], $methods)) return true;
194 194
 
195
-      } else {
195
+        } else {
196 196
 
197 197
         return false;
198
-      }
198
+        }
199 199
     }
200 200
 
201 201
     return $this->app->request->method() == $method;
202
-  }
202
+    }
203 203
 
204
-  public function getArgumentsFor($pattern)
205
-  {
204
+    public function getArgumentsFor($pattern)
205
+    {
206 206
     $url = $this->app->request->url();
207 207
 
208 208
     preg_match($pattern, $url, $matches);
@@ -210,15 +210,15 @@  discard block
 block discarded – undo
210 210
     array_shift($matches);
211 211
 
212 212
     return $matches;
213
-  }
213
+    }
214 214
 
215
-  public function getCurrent($key)
216
-  {
215
+    public function getCurrent($key)
216
+    {
217 217
     return $this->current[$key];
218
-  }
218
+    }
219 219
 
220
-  private function middleware($middleware, $from = 'admin')
221
-  {
220
+    private function middleware($middleware, $from = 'admin')
221
+    {
222 222
     $middlewareInterface = 'App\\Middleware\\MiddlewaresInterface';
223 223
 
224 224
     $middlewares = $this->app->alias['middlewares'][$from];
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     $middlewareClass = $middlewares[$middleware];
227 227
 
228 228
     if (! in_array($middlewareInterface, class_implements($middlewareClass))) {
229
-      throw new Exception("$middlewareClass not Implement");
229
+        throw new Exception("$middlewareClass not Implement");
230 230
     }
231 231
 
232 232
     $middlewareObject = new $middlewareClass;
@@ -236,5 +236,5 @@  discard block
 block discarded – undo
236 236
     if ($output && $output === static::NEXT) $output = '';
237 237
 
238 238
     return $output;
239
-  }
239
+    }
240 240
 }
241 241
\ No newline at end of file
Please login to merge, or discard this patch.
Core/System/Http/Request.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -6,23 +6,23 @@  discard block
 block discarded – undo
6 6
 
7 7
 class Request
8 8
 {
9
-  private $app;
9
+    private $app;
10 10
 
11
-  private $url;
11
+    private $url;
12 12
 
13
-  private $baseUrl;
13
+    private $baseUrl;
14 14
 
15
-  private $files = [];
15
+    private $files = [];
16 16
 
17
-  private $link;
17
+    private $link;
18 18
 
19
-  public function __construct(Application $app)
20
-  {
19
+    public function __construct(Application $app)
20
+    {
21 21
     $this->app = $app;
22
-  }
22
+    }
23 23
 
24
-  public function prepareUrl()
25
-  {
24
+    public function prepareUrl()
25
+    {
26 26
     $script = dirname($this->server('SCRIPT_NAME'));
27 27
 
28 28
     $requestUri = $this->server('REQUEST_URI');
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 
32 32
     if (! in_array($script, ['/', '\\'])) {
33 33
 
34
-      $this->url = preg_replace('#^' . $script . '#', '', $requestUri);
34
+        $this->url = preg_replace('#^' . $script . '#', '', $requestUri);
35 35
     } else {
36 36
 
37
-      $this->url = $requestUri;
37
+        $this->url = $requestUri;
38 38
     }
39 39
 
40 40
     if ($this->url !== '/') $this->url = rtrim($this->url, '/');
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
 
44 44
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
45 45
 
46
-      $isSecure = true;
46
+        $isSecure = true;
47 47
 
48 48
     }
49 49
     elseif (! empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || ! empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
50
-      $isSecure = true;
50
+        $isSecure = true;
51 51
     }
52 52
 
53 53
     $REQUEST_PROTOCOL = $isSecure ? 'https' : 'http';
@@ -55,51 +55,51 @@  discard block
 block discarded – undo
55 55
     $this->link = $REQUEST_PROTOCOL . '://' . $this->server('HTTP_HOST');
56 56
 
57 57
     $this->baseUrl = $this->link . $requestUri;
58
-  }
58
+    }
59 59
 
60
-  public function get($key)
61
-  {
60
+    public function get($key)
61
+    {
62 62
     $value = array_get($_GET, $key, $default);
63 63
 
64 64
     if (is_array($value)) {
65
-      $value = array_filter($value);
65
+        $value = array_filter($value);
66 66
     } else {
67
-      $value = trim($value);
67
+        $value = trim($value);
68 68
     }
69 69
 
70 70
     return $value;
71
-  }
71
+    }
72 72
 
73
-  public function post($key)
74
-  {
73
+    public function post($key)
74
+    {
75 75
     $value = array_get($_POST, $key, $default);
76 76
 
77 77
     if (is_array($value)) {
78
-      $value = array_filter($value);
78
+        $value = array_filter($value);
79 79
     } else {
80
-      $value = trim($value);
80
+        $value = trim($value);
81 81
     }
82 82
 
83 83
     return $value;
84
-  }
84
+    }
85 85
 
86
-  public function setPost($key, $value)
87
-  {
86
+    public function setPost($key, $value)
87
+    {
88 88
     $_POST[$key] = $value;
89
-  }
89
+    }
90 90
 
91
-  public function posts()
92
-  {
91
+    public function posts()
92
+    {
93 93
     return $_POST;
94
-  }
94
+    }
95 95
 
96
-  public function files()
97
-  {
96
+    public function files()
97
+    {
98 98
     return $_FILES;
99
-  }
99
+    }
100 100
 
101
-  public function file($input)
102
-  {
101
+    public function file($input)
102
+    {
103 103
     if (isset($this->files[$input])) return $this->files[$input];
104 104
 
105 105
     $upoadedFile = new UploadeFile($this->app, $input);
@@ -107,35 +107,35 @@  discard block
 block discarded – undo
107 107
     $this->files[$input] = $upoadedFile;
108 108
 
109 109
     return $this->files[$input];
110
-  }
110
+    }
111 111
 
112
-  public function server($key)
113
-  {
112
+    public function server($key)
113
+    {
114 114
     return array_get($_SERVER, $key);
115
-  }
115
+    }
116 116
 
117
-  public function method()
118
-  {
117
+    public function method()
118
+    {
119 119
     return $this->server('REQUEST_METHOD');
120
-  }
120
+    }
121 121
 
122
-  public function referer()
123
-  {
122
+    public function referer()
123
+    {
124 124
     return $this->server('HTTP_REFERER');
125
-  }
125
+    }
126 126
 
127
-  public function baseUrl()
128
-  {
127
+    public function baseUrl()
128
+    {
129 129
     return $this->baseUrl;
130
-  }
130
+    }
131 131
 
132
-  public function url()
133
-  {
132
+    public function url()
133
+    {
134 134
     return $this->url;
135
-  }
135
+    }
136 136
 
137
-  public function link()
138
-  {
137
+    public function link()
138
+    {
139 139
     return $this->link;
140
-  }
140
+    }
141 141
 }
142 142
\ No newline at end of file
Please login to merge, or discard this patch.
Core/System/Http/Response.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,44 +6,44 @@
 block discarded – undo
6 6
 
7 7
 class Response
8 8
 {
9
-  private $app;
9
+    private $app;
10 10
 
11
-  private $headers = [];
11
+    private $headers = [];
12 12
 
13
-  private $content = '';
13
+    private $content = '';
14 14
 
15
-  public function __construct(Application $app)
16
-  {
15
+    public function __construct(Application $app)
16
+    {
17 17
     $this->app = $app;
18
-  }
18
+    }
19 19
 
20
-  public function setOutput($content)
21
-  {
20
+    public function setOutput($content)
21
+    {
22 22
     $this->content = $content;
23
-  }
23
+    }
24 24
 
25
-  public function setHeaders($header, $value)
26
-  {
25
+    public function setHeaders($header, $value)
26
+    {
27 27
     $this->headers[$header] = $value;
28
-  }
28
+    }
29 29
 
30
-  public function sendOutput()
31
-  {
30
+    public function sendOutput()
31
+    {
32 32
     echo $this->content;
33
-  }
33
+    }
34 34
 
35
-  public function sendHeaders()
36
-  {
35
+    public function sendHeaders()
36
+    {
37 37
     foreach($this->headers as $header => $value)
38 38
     {
39
-      header($header . ':' . $value);
39
+        header($header . ':' . $value);
40
+    }
40 41
     }
41
-  }
42 42
 
43
-  public function send()
44
-  {
43
+    public function send()
44
+    {
45 45
     $this->sendHeaders();
46 46
 
47 47
     $this->sendOutput();
48
-  }
48
+    }
49 49
 }
50 50
\ No newline at end of file
Please login to merge, or discard this patch.
Core/System/Paginatio.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -4,87 +4,87 @@
 block discarded – undo
4 4
 
5 5
 class Pagination
6 6
 {
7
-  private $app;
7
+    private $app;
8 8
 
9
-  private $totalItems;
9
+    private $totalItems;
10 10
 
11
-  private $itemsPerPage = 10;
11
+    private $itemsPerPage = 10;
12 12
 
13
-  private $lastPage;
13
+    private $lastPage;
14 14
 
15
-  private $page = 1;
15
+    private $page = 1;
16 16
 
17
-  public function __construct(Application $app)
18
-  {
17
+    public function __construct(Application $app)
18
+    {
19 19
     $this->app = $app;
20 20
 
21 21
     $this->setCurrentPage();
22
-  }
22
+    }
23 23
 
24
-  private function setCurrentPage()
25
-  {
24
+    private function setCurrentPage()
25
+    {
26 26
     $page = $this->app->request->get('page');
27 27
 
28 28
     if (! is_numeric($page) || $page < 1) {
29
-      $page = 1;
29
+        $page = 1;
30 30
     }
31 31
 
32 32
     $this->page = $page;
33
-  }
33
+    }
34 34
 
35
-  public function page()
36
-  {
35
+    public function page()
36
+    {
37 37
     return $this->page;
38
-  }
38
+    }
39 39
 
40
-  public function itemsPerPage()
41
-  {
40
+    public function itemsPerPage()
41
+    {
42 42
     return $this->itemsPerPage;
43
-  }
43
+    }
44 44
 
45
-  public function totalItems()
46
-  {
45
+    public function totalItems()
46
+    {
47 47
     return $this->totalItems;
48
-  }
48
+    }
49 49
 
50
-  public function last()
51
-  {
50
+    public function last()
51
+    {
52 52
     return $this->lastPage;
53
-  }
53
+    }
54 54
 
55
-  public function next()
56
-  {
55
+    public function next()
56
+    {
57 57
     return $this->page + 1;
58
-  }
58
+    }
59 59
 
60
-  public function prev()
61
-  {
60
+    public function prev()
61
+    {
62 62
     return $this->page - 1;
63
-  }
63
+    }
64 64
 
65
-  public function setTotalItems($totalItems)
66
-  {
65
+    public function setTotalItems($totalItems)
66
+    {
67 67
     $this->totalItems = $totalItems;
68 68
 
69 69
     return $this;
70
-  }
70
+    }
71 71
 
72
-  public function setItemsPerPage($itemsPerPage)
73
-  {
72
+    public function setItemsPerPage($itemsPerPage)
73
+    {
74 74
     $this->itemsPerPage = $itemsPerPage;
75 75
 
76 76
     return $this;
77
-  }
77
+    }
78 78
 
79
-  public function paginate()
80
-  {
79
+    public function paginate()
80
+    {
81 81
     $this->setLastPage();
82 82
 
83 83
     return $this;
84
-  }
84
+    }
85 85
 
86
-  private function setLastPage()
87
-  {
86
+    private function setLastPage()
87
+    {
88 88
     $this->lastPage = ceil($this->totalItems / $this->itemsPerPage);
89
-  }
89
+    }
90 90
 }
91 91
\ No newline at end of file
Please login to merge, or discard this patch.
Core/System/Database.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -8,92 +8,92 @@  discard block
 block discarded – undo
8 8
 
9 9
 class Database
10 10
 {
11
-  private $app;
11
+    private $app;
12 12
 
13
-  private static $connection;
13
+    private static $connection;
14 14
 
15
-  private $table;
15
+    private $table;
16 16
 
17
-  private $rows;
17
+    private $rows;
18 18
 
19
-  private $lastId;
19
+    private $lastId;
20 20
 
21
-  private $data = [];
21
+    private $data = [];
22 22
 
23
-  private $bindings = [];
23
+    private $bindings = [];
24 24
 
25
-  private $selects = [];
25
+    private $selects = [];
26 26
 
27
-  private $joins = [];
27
+    private $joins = [];
28 28
 
29
-  private $wheres = [];
29
+    private $wheres = [];
30 30
 
31
-  private $havings = [];
31
+    private $havings = [];
32 32
 
33
-  private $orderBy = [];
33
+    private $orderBy = [];
34 34
 
35
-  private $limit;
35
+    private $limit;
36 36
 
37
-  private $offset;
37
+    private $offset;
38 38
 
39
-  private $groupBy = [];
39
+    private $groupBy = [];
40 40
 
41
-  public function __construct(Application $app)
42
-  {
41
+    public function __construct(Application $app)
42
+    {
43 43
     $this->app = $app;
44 44
 
45 45
     if (! $this->isConnected()) {
46
-      $this->connect();
46
+        $this->connect();
47
+    }
47 48
     }
48
-  }
49 49
 
50
-  private function  isConnected()
51
-  {
50
+    private function  isConnected()
51
+    {
52 52
     return static::$connection instanceof PDO;
53
-  }
53
+    }
54 54
 
55
-  private function connect()
56
-  {
55
+    private function connect()
56
+    {
57 57
     $data = $this->app->config['db'];
58 58
 
59 59
     extract($data);
60 60
 
61 61
     try {
62
-      static::$connection  = new PDO('mysql:host=' . $server . ';dbname=' . $dbname, $dbuser, $dbpass);
62
+        static::$connection  = new PDO('mysql:host=' . $server . ';dbname=' . $dbname, $dbuser, $dbpass);
63 63
 
64
-      static::$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
64
+        static::$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
65 65
 
66
-      static::$connection->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
66
+        static::$connection->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
67 67
 
68
-      static::$connection->exec('SET NAMES utf8');
68
+        static::$connection->exec('SET NAMES utf8');
69 69
 
70 70
     } catch (PDOException $e) {
71 71
 
72
-      throw new Exception($e->getMessage());
72
+        throw new Exception($e->getMessage());
73
+    }
73 74
     }
74
-  }
75 75
 
76
-  public function connection()
77
-  {
76
+    public function connection()
77
+    {
78 78
     return static::$connection;
79
-  }
79
+    }
80 80
 
81
-  public function table($table)
82
-  {
81
+    public function table($table)
82
+    {
83 83
     $this->table = $table;
84 84
 
85 85
     return $this;
86
-  }
86
+    }
87 87
 
88
-  public function select(...$select)
89
-  {
88
+    public function select(...$select)
89
+    {
90 90
     $this->selects = array_merge($this->selects, $select);
91 91
 
92 92
     return $this;
93
-  }
93
+    }
94 94
 
95
-  public function join($join, $localId = null, $forginId = null)
96
-  {
95
+    public function join($join, $localId = null, $forginId = null)
96
+    {
97 97
     if (! $localId)  $localId =  trim($join, 's' ). '_id';
98 98
 
99 99
     if (! $forginId) $forginId =  'id';
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
     $this->joins[] = $sql;
104 104
 
105 105
     return $this;
106
-  }
106
+    }
107 107
 
108
-  public function where(...$bindings)
109
-  {
108
+    public function where(...$bindings)
109
+    {
110 110
     $sql = array_shift($bindings);
111 111
 
112 112
     if (is_array($bindings[0])) $bindings = $bindings[0];
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
     $this->wheres[] = $sql;
117 117
 
118 118
     return $this;
119
-  }
119
+    }
120 120
 
121
-  public function having()
122
-  {
121
+    public function having()
122
+    {
123 123
     $bindings = func_get_args();
124 124
 
125 125
     $sql = array_shift($bindings);
@@ -129,40 +129,40 @@  discard block
 block discarded – undo
129 129
     $this->havings[] = $sql;
130 130
 
131 131
     return $this;
132
-  }
132
+    }
133 133
 
134
-  public function groupBy(...$arguments)
135
-  {
134
+    public function groupBy(...$arguments)
135
+    {
136 136
     $this->groupBy = $arguments;
137 137
 
138 138
     return $this;
139
-  }
139
+    }
140 140
 
141
-  public function limit($limit, $offset = 0)
142
-  {
141
+    public function limit($limit, $offset = 0)
142
+    {
143 143
     $this->limit = $limit;
144 144
 
145 145
     $this->offset = $offset;
146 146
 
147 147
     return $this;
148
-  }
148
+    }
149 149
 
150
-  public function rows()
151
-  {
150
+    public function rows()
151
+    {
152 152
     return $this->rows;
153
-  }
153
+    }
154 154
 
155
-  public function orderBy($orderBy, $sort = 'ASC')
156
-  {
155
+    public function orderBy($orderBy, $sort = 'ASC')
156
+    {
157 157
     $this->orderBy = [$orderBy, $sort];
158 158
 
159 159
     return $this;
160
-  }
160
+    }
161 161
 
162
-  public function fetch($table = null)
163
-  {
162
+    public function fetch($table = null)
163
+    {
164 164
     if ($table) {
165
-      $this->table($table);
165
+        $this->table($table);
166 166
     }
167 167
 
168 168
     $sql = $this->fetchStatment();
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
     $this->rows = $query->rowCount();
175 175
 
176 176
     return $result;
177
-  }
177
+    }
178 178
 
179
-  public function fetchAll($table = null)
180
-  {
179
+    public function fetchAll($table = null)
180
+    {
181 181
     if ($table) {
182
-      $this->table($table);
182
+        $this->table($table);
183 183
     }
184 184
 
185 185
     $sql = $this->fetchStatment();
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
     $this->rows = $query->rowCount();
192 192
 
193 193
     return $results;
194
-  }
194
+    }
195 195
 
196
-  private function fetchStatment()
197
-  {
196
+    private function fetchStatment()
197
+    {
198 198
     $sql = 'SELECT ';
199 199
 
200 200
     $sql .= $this->selects ? implode(', ', $this->selects) : '*';
@@ -203,74 +203,74 @@  discard block
 block discarded – undo
203 203
 
204 204
     if ($this->joins) {
205 205
 
206
-      $sql .= 'LEFT JOIN ' . implode(' ', $this->joins);
206
+        $sql .= 'LEFT JOIN ' . implode(' ', $this->joins);
207 207
     }
208 208
 
209 209
     if ($this->wheres) {
210 210
 
211
-      $sql .= ' WHERE ' . implode(' ', $this->wheres);
211
+        $sql .= ' WHERE ' . implode(' ', $this->wheres);
212 212
     }
213 213
 
214 214
     if ($this->havings) {
215 215
 
216
-      $sql .= ' HAVING ' . implode(' ', $this->havings) . ' ';
216
+        $sql .= ' HAVING ' . implode(' ', $this->havings) . ' ';
217 217
     }
218 218
 
219 219
     if ($this->orderBy) {
220 220
 
221
-      $sql .= ' ORDER BY ' . implode (' ', $this->orderBy);
221
+        $sql .= ' ORDER BY ' . implode (' ', $this->orderBy);
222 222
     }
223 223
 
224 224
     if ($this->limit) {
225 225
 
226
-      $sql .= ' LIMIT ' . $this->limit;
226
+        $sql .= ' LIMIT ' . $this->limit;
227 227
     }
228 228
 
229 229
     if ($this->offset) {
230 230
 
231
-      $sql .= ' OFFSET ' . $this->offset;
231
+        $sql .= ' OFFSET ' . $this->offset;
232 232
     }
233 233
 
234 234
     if ($this->groupBy) {
235
-      $sql .= ' GROUP BY ' . implode(' ' , $this->groupBy);
235
+        $sql .= ' GROUP BY ' . implode(' ' , $this->groupBy);
236 236
     }
237 237
 
238 238
     return $sql;
239
-  }
239
+    }
240 240
 
241
-  public function lastId()
242
-  {
241
+    public function lastId()
242
+    {
243 243
     return $this->lastId;
244
-  }
244
+    }
245 245
 
246
-  public function from($table)
247
-  {
246
+    public function from($table)
247
+    {
248 248
     return $this->table($table);
249
-  }
249
+    }
250 250
 
251
-  public function data($key, $value = null)
252
-  {
251
+    public function data($key, $value = null)
252
+    {
253 253
     if (is_array($key)) {
254 254
 
255
-      $this->data = array_merge($this->data, $key);
255
+        $this->data = array_merge($this->data, $key);
256 256
 
257
-      $this->addToBindings($key);
257
+        $this->addToBindings($key);
258 258
 
259 259
     } else {
260 260
 
261
-      $this->data[$key] = $value;
261
+        $this->data[$key] = $value;
262 262
 
263
-      $this->addToBindings($value);
263
+        $this->addToBindings($value);
264 264
 
265 265
     }
266 266
 
267 267
     return $this;
268
-  }
268
+    }
269 269
 
270
-  public function insert($table = null)
271
-  {
270
+    public function insert($table = null)
271
+    {
272 272
     if ($table) {
273
-      $this->table($table);
273
+        $this->table($table);
274 274
     }
275 275
 
276 276
     $sql = 'INSERT INTO ' . $this->table . ' SET ';
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
     $this->lastId = $this->connection()->lastInsertId();
283 283
 
284 284
     return $this;
285
-  }
285
+    }
286 286
 
287
-  public function update($table = null)
288
-  {
287
+    public function update($table = null)
288
+    {
289 289
     if ($table) {
290
-      $this->table($table);
290
+        $this->table($table);
291 291
     }
292 292
 
293 293
     $sql = 'UPDATE ' . $this->table . ' SET ';
@@ -295,69 +295,69 @@  discard block
 block discarded – undo
295 295
     $sql .= $this->setField();
296 296
 
297 297
     if ($this->wheres) {
298
-      $sql .= ' WHERE ' . implode('', $this->wheres);
298
+        $sql .= ' WHERE ' . implode('', $this->wheres);
299 299
     }
300 300
 
301 301
     $this->query($sql, $this->bindings);
302 302
 
303 303
     return $this;
304
-  }
304
+    }
305 305
 
306
-  public function delete($table = null)
307
-  {
306
+    public function delete($table = null)
307
+    {
308 308
     if ($table) {
309
-      $this->table($table);
309
+        $this->table($table);
310 310
     }
311 311
 
312 312
     $sql = 'DELETE FROM ' . $this->table . ' ';
313 313
 
314 314
     if ($this->wheres) {
315
-      $sql .= ' WHERE ' . implode('', $this->wheres);
315
+        $sql .= ' WHERE ' . implode('', $this->wheres);
316 316
     }
317 317
 
318 318
     $this->query($sql, $this->bindings);
319 319
 
320 320
     return $this;
321
-  }
321
+    }
322 322
 
323
-  private function setField()
324
-  {
323
+    private function setField()
324
+    {
325 325
     $sql = '';
326 326
 
327 327
     foreach($this->data as $key => $value) {
328 328
 
329
-      $sql .= '`' . $key . '` = ? ,';
329
+        $sql .= '`' . $key . '` = ? ,';
330 330
     }
331 331
 
332 332
     $sql = rtrim($sql, ' ,');
333 333
 
334 334
     return $sql;
335
-  }
335
+    }
336 336
 
337
-  private function addToBindings($value)
338
-  {
337
+    private function addToBindings($value)
338
+    {
339 339
     if (is_array($value)) {
340 340
 
341
-      $this->bindings = array_merge($this->bindings, array_values($value));
341
+        $this->bindings = array_merge($this->bindings, array_values($value));
342 342
     } else {
343 343
 
344
-      $this->bindings[] = $value;
344
+        $this->bindings[] = $value;
345
+    }
345 346
     }
346
-  }
347 347
 
348
-  public function query(...$bindings)
349
-  {
348
+    public function query(...$bindings)
349
+    {
350 350
     $sql = array_shift($bindings);
351 351
 
352 352
     if (count($bindings) == 1 AND is_array($bindings[0])) {
353
-      $bindings = $bindings[0];
353
+        $bindings = $bindings[0];
354 354
     }
355 355
 
356 356
     try {
357 357
         $query = $this->connection()->prepare($sql);
358 358
 
359 359
         foreach ($bindings as $key => $value) {
360
-          $query->bindValue($key + 1, _e($value));
360
+            $query->bindValue($key + 1, _e($value));
361 361
         }
362 362
 
363 363
         $query->execute();
@@ -368,12 +368,12 @@  discard block
 block discarded – undo
368 368
 
369 369
     } catch (PDOException $e) {
370 370
 
371
-      throw new Exception($e->getMessage());
371
+        throw new Exception($e->getMessage());
372
+    }
372 373
     }
373
-  }
374 374
 
375
-  private function reset()
376
-  {
375
+    private function reset()
376
+    {
377 377
     $this->table = null;
378 378
 
379 379
     $this->rows = 0;
@@ -397,5 +397,5 @@  discard block
 block discarded – undo
397 397
     $this->offset = 0;
398 398
 
399 399
     $this->groupBy = [];
400
-  }
400
+    }
401 401
 }
402 402
\ No newline at end of file
Please login to merge, or discard this patch.