Passed
Branch master (3b33a7)
by Anu
03:20
created
app.php 3 patches
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -1,148 +1,148 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class App extends Prefab{
4
-    public $db;
4
+	public $db;
5 5
 	public $app;
6
-    public $session;
6
+	public $session;
7 7
 
8 8
 	public function __construct() {
9
-	    $this->app = $this->app ?: Base::instance();
9
+		$this->app = $this->app ?: Base::instance();
10 10
 	}
11 11
 
12
-    static public function singleton() {
13
-        if (Registry::exists('APP'))
14
-            $app = Registry::get('APP');
15
-        else {
16
-            $app = new self;
17
-            Registry::set('APP',$app);
18
-        }
19
-        return $app;
20
-    }
12
+	static public function singleton() {
13
+		if (Registry::exists('APP'))
14
+			$app = Registry::get('APP');
15
+		else {
16
+			$app = new self;
17
+			Registry::set('APP',$app);
18
+		}
19
+		return $app;
20
+	}
21 21
 
22
-    public function db() {
23
-        return $this->db ?: $this->app->DB;
24
-    }
22
+	public function db() {
23
+		return $this->db ?: $this->app->DB;
24
+	}
25 25
 
26
-    public function session() {
27
-        return $this->session ?: $this->app->SESSION;
28
-    }
26
+	public function session() {
27
+		return $this->session ?: $this->app->SESSION;
28
+	}
29 29
 
30 30
 	public function user() {
31 31
 		return $this->authenticatedUser = $this->app->get('SESSION.USER')?:false;
32 32
 	}
33 33
 
34
-    public function initialized($def = null) {
35
-        return null !== $def ? $this->app->set('INITIALIZED', $def) : $this->app->get('INITIALIZED');
36
-    }
34
+	public function initialized($def = null) {
35
+		return null !== $def ? $this->app->set('INITIALIZED', $def) : $this->app->get('INITIALIZED');
36
+	}
37 37
 
38
-    public function config($key = null) {
39
-        return $this->app->get($key?:'CONFIG') ;
40
-    }
38
+	public function config($key = null) {
39
+		return $this->app->get($key?:'CONFIG') ;
40
+	}
41 41
 
42
-    public function status() {
43
-        return $this->app->IS_LIVE;
44
-    }
42
+	public function status() {
43
+		return $this->app->IS_LIVE;
44
+	}
45 45
 
46
-    public function run() {
47
-        $this->loadConfig();
48
-        $this->loadRoutes();
49
-        $this->checkForMaintenance();
50
-        $this->configureDebug();
51
-	    $this->configureDB();
52
-	    $this->configureSession();
53
-        $this->configureAssets();
46
+	public function run() {
47
+		$this->loadConfig();
48
+		$this->loadRoutes();
49
+		$this->checkForMaintenance();
50
+		$this->configureDebug();
51
+		$this->configureDB();
52
+		$this->configureSession();
53
+		$this->configureAssets();
54 54
 		$this->registerErrorHandler();
55
-	    $this->initialized(true);
55
+		$this->initialized(true);
56 56
 		$this->app->run();
57
-    }
58
-
59
-    public function loadRoutes($file = null){
60
-        if($file) {
61
-            $this->app->config(base_path('routes/'.$file));
62
-        }else{
63
-            foreach(glob(base_path('routes/*.ini')) as $file) {
64
-                $this->app->config($file);
65
-            }
66
-        }
67
-    }
68
-
69
-    public function loadConfig($file = null){
70
-        if($file) {
71
-            $this->app->config(base_path('config/'.$file));
72
-        }else{
73
-            foreach(glob(base_path('config/*.ini')) as $file) {
74
-                $this->app->config($file);
75
-            }
76
-        }
77
-    }
57
+	}
58
+
59
+	public function loadRoutes($file = null){
60
+		if($file) {
61
+			$this->app->config(base_path('routes/'.$file));
62
+		}else{
63
+			foreach(glob(base_path('routes/*.ini')) as $file) {
64
+				$this->app->config($file);
65
+			}
66
+		}
67
+	}
68
+
69
+	public function loadConfig($file = null){
70
+		if($file) {
71
+			$this->app->config(base_path('config/'.$file));
72
+		}else{
73
+			foreach(glob(base_path('config/*.ini')) as $file) {
74
+				$this->app->config($file);
75
+			}
76
+		}
77
+	}
78 78
 
79 79
 	public function checkForMaintenance() {
80 80
 		if(!$this->status()) {
81
-	       	template('maintenance');
82
-		    exit();
83
-        }
84
-	}
85
-
86
-    public function configureDebug() {
87
-	    if(!$this->app->DEV) {
88
-	        $this->app->set('DEBUG', 0);
89
-        }
90
-    }
91
-
92
-    public function configureDB() {
93
-        $type = strtolower($this->app->DB_TYPE);
94
-
95
-        if($type == 'jig'){
96
-            $this->db = new DB\Jig($this->app->DB_PATH, DB\Jig::FORMAT_JSON);
97
-        }else if($type == 'sql'){
98
-            $this->db = new DB\SQL($this->app->DB, $this->app->DB_USER, $this->app->DB_PSWD);
99
-        }else if($type == 'mongo'){
100
-            $this->db = new DB\Mongo($this->app->DB, $this->app->DB_USER);
101
-        }
102
-        $this->app->set('DB', $this->db);
103
-    }
104
-
105
-    public function configureSession() {
106
-        $type = strtolower($this->app->SESSION);
107
-
108
-        if($type) {
109
-            if($this->app->CSRF && ('jig' == $type || 'sql' == $type || 'mongo' == $type)) {
110
-                $this->configureCSRF($type);
111
-            }else if($this->app->CSRF){
112
-                $this->session = new Session(null, 'CSRF');
113
-            }else{
114
-                if($type == 'jig' || $type == 'mongo' || $type == 'sql'){
115
-                    if($type == 'jig' || $type == 'mongo'){
116
-                        $type = ucfirst($type);
117
-                    }else if($type == 'sql') {
118
-                        $type = strtoupper($type);
119
-                    }
120
-                    $session = str_ireplace('/', '', 'DB\/'.$type.'\Session');
121
-                    $this->session = new $session($this->app->DB);
122
-                }else{
123
-                    $this->session = new Session();
124
-                }
125
-            }
126
-            $this->app->set('SESSION', $this->session);
127
-        }
128
-    }
129
-
130
-    public function configureCSRF($type) {
131
-        if($type == 'jig' || $type == 'mongo'){
132
-            $type = ucfirst($type);
133
-        }else if($type == 'sql') {
134
-            $type = strtoupper($type);
135
-        }
136
-        $session = str_ireplace('/', '', 'DB\/'.$type.'\Session');
137
-        $this->session = new $session($this->app->DB, 'sessions', null, 'CSRF');
138
-    }
139
-
140
-    public function configureAssets() {
141
-        $assets = Assets::instance();
142
-        $this->app->set('ASSETS.onFileNotFound',function($file) use ($f3){
143
-            echo 'file not found: '.$file;
144
-        });
145
-    }
81
+		   	template('maintenance');
82
+			exit();
83
+		}
84
+	}
85
+
86
+	public function configureDebug() {
87
+		if(!$this->app->DEV) {
88
+			$this->app->set('DEBUG', 0);
89
+		}
90
+	}
91
+
92
+	public function configureDB() {
93
+		$type = strtolower($this->app->DB_TYPE);
94
+
95
+		if($type == 'jig'){
96
+			$this->db = new DB\Jig($this->app->DB_PATH, DB\Jig::FORMAT_JSON);
97
+		}else if($type == 'sql'){
98
+			$this->db = new DB\SQL($this->app->DB, $this->app->DB_USER, $this->app->DB_PSWD);
99
+		}else if($type == 'mongo'){
100
+			$this->db = new DB\Mongo($this->app->DB, $this->app->DB_USER);
101
+		}
102
+		$this->app->set('DB', $this->db);
103
+	}
104
+
105
+	public function configureSession() {
106
+		$type = strtolower($this->app->SESSION);
107
+
108
+		if($type) {
109
+			if($this->app->CSRF && ('jig' == $type || 'sql' == $type || 'mongo' == $type)) {
110
+				$this->configureCSRF($type);
111
+			}else if($this->app->CSRF){
112
+				$this->session = new Session(null, 'CSRF');
113
+			}else{
114
+				if($type == 'jig' || $type == 'mongo' || $type == 'sql'){
115
+					if($type == 'jig' || $type == 'mongo'){
116
+						$type = ucfirst($type);
117
+					}else if($type == 'sql') {
118
+						$type = strtoupper($type);
119
+					}
120
+					$session = str_ireplace('/', '', 'DB\/'.$type.'\Session');
121
+					$this->session = new $session($this->app->DB);
122
+				}else{
123
+					$this->session = new Session();
124
+				}
125
+			}
126
+			$this->app->set('SESSION', $this->session);
127
+		}
128
+	}
129
+
130
+	public function configureCSRF($type) {
131
+		if($type == 'jig' || $type == 'mongo'){
132
+			$type = ucfirst($type);
133
+		}else if($type == 'sql') {
134
+			$type = strtoupper($type);
135
+		}
136
+		$session = str_ireplace('/', '', 'DB\/'.$type.'\Session');
137
+		$this->session = new $session($this->app->DB, 'sessions', null, 'CSRF');
138
+	}
139
+
140
+	public function configureAssets() {
141
+		$assets = Assets::instance();
142
+		$this->app->set('ASSETS.onFileNotFound',function($file) use ($f3){
143
+			echo 'file not found: '.$file;
144
+		});
145
+	}
146 146
 
147 147
 	public function registerErrorHandler() {
148 148
 		if($this->app->DEV) {
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class App extends Prefab{
3
+class App extends Prefab {
4 4
     public $db;
5 5
 	public $app;
6 6
     public $session;
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
             $app = Registry::get('APP');
15 15
         else {
16 16
             $app = new self;
17
-            Registry::set('APP',$app);
17
+            Registry::set('APP', $app);
18 18
         }
19 19
         return $app;
20 20
     }
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     }
29 29
 
30 30
 	public function user() {
31
-		return $this->authenticatedUser = $this->app->get('SESSION.USER')?:false;
31
+		return $this->authenticatedUser = $this->app->get('SESSION.USER') ?: false;
32 32
 	}
33 33
 
34 34
     public function initialized($def = null) {
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     }
37 37
 
38 38
     public function config($key = null) {
39
-        return $this->app->get($key?:'CONFIG') ;
39
+        return $this->app->get($key ?: 'CONFIG');
40 40
     }
41 41
 
42 42
     public function status() {
@@ -56,35 +56,35 @@  discard block
 block discarded – undo
56 56
 		$this->app->run();
57 57
     }
58 58
 
59
-    public function loadRoutes($file = null){
60
-        if($file) {
59
+    public function loadRoutes($file = null) {
60
+        if ($file) {
61 61
             $this->app->config(base_path('routes/'.$file));
62
-        }else{
63
-            foreach(glob(base_path('routes/*.ini')) as $file) {
62
+        }else {
63
+            foreach (glob(base_path('routes/*.ini')) as $file) {
64 64
                 $this->app->config($file);
65 65
             }
66 66
         }
67 67
     }
68 68
 
69
-    public function loadConfig($file = null){
70
-        if($file) {
69
+    public function loadConfig($file = null) {
70
+        if ($file) {
71 71
             $this->app->config(base_path('config/'.$file));
72
-        }else{
73
-            foreach(glob(base_path('config/*.ini')) as $file) {
72
+        }else {
73
+            foreach (glob(base_path('config/*.ini')) as $file) {
74 74
                 $this->app->config($file);
75 75
             }
76 76
         }
77 77
     }
78 78
 
79 79
 	public function checkForMaintenance() {
80
-		if(!$this->status()) {
80
+		if (!$this->status()) {
81 81
 	       	template('maintenance');
82 82
 		    exit();
83 83
         }
84 84
 	}
85 85
 
86 86
     public function configureDebug() {
87
-	    if(!$this->app->DEV) {
87
+	    if (!$this->app->DEV) {
88 88
 	        $this->app->set('DEBUG', 0);
89 89
         }
90 90
     }
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
     public function configureDB() {
93 93
         $type = strtolower($this->app->DB_TYPE);
94 94
 
95
-        if($type == 'jig'){
95
+        if ($type == 'jig') {
96 96
             $this->db = new DB\Jig($this->app->DB_PATH, DB\Jig::FORMAT_JSON);
97
-        }else if($type == 'sql'){
97
+        }else if ($type == 'sql') {
98 98
             $this->db = new DB\SQL($this->app->DB, $this->app->DB_USER, $this->app->DB_PSWD);
99
-        }else if($type == 'mongo'){
99
+        }else if ($type == 'mongo') {
100 100
             $this->db = new DB\Mongo($this->app->DB, $this->app->DB_USER);
101 101
         }
102 102
         $this->app->set('DB', $this->db);
@@ -105,21 +105,21 @@  discard block
 block discarded – undo
105 105
     public function configureSession() {
106 106
         $type = strtolower($this->app->SESSION);
107 107
 
108
-        if($type) {
109
-            if($this->app->CSRF && ('jig' == $type || 'sql' == $type || 'mongo' == $type)) {
108
+        if ($type) {
109
+            if ($this->app->CSRF && ('jig' == $type || 'sql' == $type || 'mongo' == $type)) {
110 110
                 $this->configureCSRF($type);
111
-            }else if($this->app->CSRF){
111
+            }else if ($this->app->CSRF) {
112 112
                 $this->session = new Session(null, 'CSRF');
113
-            }else{
114
-                if($type == 'jig' || $type == 'mongo' || $type == 'sql'){
115
-                    if($type == 'jig' || $type == 'mongo'){
113
+            }else {
114
+                if ($type == 'jig' || $type == 'mongo' || $type == 'sql') {
115
+                    if ($type == 'jig' || $type == 'mongo') {
116 116
                         $type = ucfirst($type);
117
-                    }else if($type == 'sql') {
117
+                    }else if ($type == 'sql') {
118 118
                         $type = strtoupper($type);
119 119
                     }
120 120
                     $session = str_ireplace('/', '', 'DB\/'.$type.'\Session');
121 121
                     $this->session = new $session($this->app->DB);
122
-                }else{
122
+                }else {
123 123
                     $this->session = new Session();
124 124
                 }
125 125
             }
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
     }
129 129
 
130 130
     public function configureCSRF($type) {
131
-        if($type == 'jig' || $type == 'mongo'){
131
+        if ($type == 'jig' || $type == 'mongo') {
132 132
             $type = ucfirst($type);
133
-        }else if($type == 'sql') {
133
+        }else if ($type == 'sql') {
134 134
             $type = strtoupper($type);
135 135
         }
136 136
         $session = str_ireplace('/', '', 'DB\/'.$type.'\Session');
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 
140 140
     public function configureAssets() {
141 141
         $assets = Assets::instance();
142
-        $this->app->set('ASSETS.onFileNotFound',function($file) use ($f3){
142
+        $this->app->set('ASSETS.onFileNotFound', function($file) use ($f3){
143 143
             echo 'file not found: '.$file;
144 144
         });
145 145
     }
146 146
 
147 147
 	public function registerErrorHandler() {
148
-		if($this->app->DEV) {
148
+		if ($this->app->DEV) {
149 149
 			Falsum\Run::handler($this->app->DEBUG != 3);
150
-		}else{
150
+		}else {
151 151
 			$this->app->set('ONERROR', 'App\Core\Controllers\ErrorController->init');
152 152
 		}
153 153
 	}
Please login to merge, or discard this patch.
Braces   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  discard block
 block discarded – undo
10 10
 	}
11 11
 
12 12
     static public function singleton() {
13
-        if (Registry::exists('APP'))
14
-            $app = Registry::get('APP');
15
-        else {
13
+        if (Registry::exists('APP')) {
14
+                    $app = Registry::get('APP');
15
+        } else {
16 16
             $app = new self;
17 17
             Registry::set('APP',$app);
18 18
         }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     public function loadRoutes($file = null){
60 60
         if($file) {
61 61
             $this->app->config(base_path('routes/'.$file));
62
-        }else{
62
+        } else{
63 63
             foreach(glob(base_path('routes/*.ini')) as $file) {
64 64
                 $this->app->config($file);
65 65
             }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     public function loadConfig($file = null){
70 70
         if($file) {
71 71
             $this->app->config(base_path('config/'.$file));
72
-        }else{
72
+        } else{
73 73
             foreach(glob(base_path('config/*.ini')) as $file) {
74 74
                 $this->app->config($file);
75 75
             }
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 
95 95
         if($type == 'jig'){
96 96
             $this->db = new DB\Jig($this->app->DB_PATH, DB\Jig::FORMAT_JSON);
97
-        }else if($type == 'sql'){
97
+        } else if($type == 'sql'){
98 98
             $this->db = new DB\SQL($this->app->DB, $this->app->DB_USER, $this->app->DB_PSWD);
99
-        }else if($type == 'mongo'){
99
+        } else if($type == 'mongo'){
100 100
             $this->db = new DB\Mongo($this->app->DB, $this->app->DB_USER);
101 101
         }
102 102
         $this->app->set('DB', $this->db);
@@ -108,18 +108,18 @@  discard block
 block discarded – undo
108 108
         if($type) {
109 109
             if($this->app->CSRF && ('jig' == $type || 'sql' == $type || 'mongo' == $type)) {
110 110
                 $this->configureCSRF($type);
111
-            }else if($this->app->CSRF){
111
+            } else if($this->app->CSRF){
112 112
                 $this->session = new Session(null, 'CSRF');
113
-            }else{
113
+            } else{
114 114
                 if($type == 'jig' || $type == 'mongo' || $type == 'sql'){
115 115
                     if($type == 'jig' || $type == 'mongo'){
116 116
                         $type = ucfirst($type);
117
-                    }else if($type == 'sql') {
117
+                    } else if($type == 'sql') {
118 118
                         $type = strtoupper($type);
119 119
                     }
120 120
                     $session = str_ireplace('/', '', 'DB\/'.$type.'\Session');
121 121
                     $this->session = new $session($this->app->DB);
122
-                }else{
122
+                } else{
123 123
                     $this->session = new Session();
124 124
                 }
125 125
             }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     public function configureCSRF($type) {
131 131
         if($type == 'jig' || $type == 'mongo'){
132 132
             $type = ucfirst($type);
133
-        }else if($type == 'sql') {
133
+        } else if($type == 'sql') {
134 134
             $type = strtoupper($type);
135 135
         }
136 136
         $session = str_ireplace('/', '', 'DB\/'.$type.'\Session');
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	public function registerErrorHandler() {
148 148
 		if($this->app->DEV) {
149 149
 			Falsum\Run::handler($this->app->DEBUG != 3);
150
-		}else{
150
+		} else{
151 151
 			$this->app->set('ONERROR', 'App\Core\Controllers\ErrorController->init');
152 152
 		}
153 153
 	}
Please login to merge, or discard this patch.
resources/lang/en.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
 			'numeric' => 'The {0} must be a number.',
66 66
 			'regex' => 'The {0} format is invalid.',
67 67
 			'required' => 'The {0} field is required.',
68
-    		'same' => 'The {0} and {1} must match.',
68
+			'same' => 'The {0} and {1} must match.',
69 69
 			'size' => [
70 70
 				'numeric' => 'The {0} must be {1}.',
71 71
 				'file' => 'The {0} must be {1} kilobytes.',
Please login to merge, or discard this patch.
helpers/Route.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@
 block discarded – undo
30 30
 	}
31 31
 
32 32
 	public function is($route) {
33
-	    return Str::contains($this->current(), $route);
34
-    }
33
+		return Str::contains($this->current(), $route);
34
+	}
35 35
 
36 36
 	public function currentRouteName() {
37 37
 		return $this->getRoutes()[$this->current()][0][$this->type()][3];
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 	private $app;
5 5
 
6 6
 	public function __construct() {
7
-		if($this->app == null) {
7
+		if ($this->app == null) {
8 8
 			$this->app = f3();
9 9
 		}
10 10
 	}
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	public function has($route) {
21
-		if(str_contains($route, '/')){
21
+		if (str_contains($route, '/')) {
22 22
 			return array_key_exists($route, $this->getRoutes());
23 23
 		}
24 24
 
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 
40 40
 	public function getRouteName($route) {
41 41
 		$response = null;
42
-		foreach($this->getNamedRoutes() as $name => $url) {
43
-			if($url == $route) {
42
+		foreach ($this->getNamedRoutes() as $name => $url) {
43
+			if ($url == $route) {
44 44
 				$response[] = $name;
45 45
 			}
46 46
 		}
Please login to merge, or discard this patch.
helpers/Captcha.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -73,22 +73,22 @@  discard block
 block discarded – undo
73 73
 	public function verify($code) {
74 74
 		$this->startSession();
75 75
 
76
-        $n = $this->name;
76
+		$n = $this->name;
77 77
 
78
-        $valid = isset($_SESSION[$n])
79
-            && isset($_POST[$n])
80
-            && strlen($_POST[$n])
81
-            && ($_SESSION[$n] === crypt(strtolower($_POST[$n]), $this->salt()));
78
+		$valid = isset($_SESSION[$n])
79
+			&& isset($_POST[$n])
80
+			&& strlen($_POST[$n])
81
+			&& ($_SESSION[$n] === crypt(strtolower($_POST[$n]), $this->salt()));
82 82
 
83
-        if (isset($_POST[$n])) {
84
-            unset($_POST[$n]);
85
-        }
83
+		if (isset($_POST[$n])) {
84
+			unset($_POST[$n]);
85
+		}
86 86
 
87
-        if ($valid && isset($_SESSION[$n])) {
88
-            unset($_SESSION[$n]);
89
-        }
87
+		if ($valid && isset($_SESSION[$n])) {
88
+			unset($_SESSION[$n]);
89
+		}
90 90
 
91
-        return $valid;
91
+		return $valid;
92 92
 	}
93 93
 
94 94
 	private function startSession() {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 	private function setSession($string) {
99 99
 		$this->startSession();
100
-        $_SESSION[$this->name] = crypt(strtolower($string), $this->salt());
100
+		$_SESSION[$this->name] = crypt(strtolower($string), $this->salt());
101 101
 	}
102 102
 
103 103
 	private function _generate($length) {
@@ -105,6 +105,6 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 
107 107
 	private static function salt() {
108
-        return md5(__FILE__.filemtime(__FILE__));
109
-    }
108
+		return md5(__FILE__.filemtime(__FILE__));
109
+	}
110 110
 }
111 111
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,36 +29,36 @@
 block discarded – undo
29 29
 	* Captcha::instance()->render(array('type'=>'img','length'=>4,'class'=>array('img'=>'captcha-img','input'=>'captcha-input')));
30 30
 	 */
31 31
 	public function render($param, $url) {
32
-		if(is_array($param)){
32
+		if (is_array($param)) {
33 33
 			$func = null;
34 34
 			$length = null;
35 35
 			$imgClass = null;
36 36
 			$inputClass = null;
37
-			foreach($param as $key => $val) {
38
-				if('type' == $key) {
37
+			foreach ($param as $key => $val) {
38
+				if ('type' == $key) {
39 39
 					$func = $key;
40 40
 				}
41
-				if('length' == $key) {
41
+				if ('length' == $key) {
42 42
 					$length = $key;
43 43
 				}
44
-				if('class' == $key && is_array($key)) {
45
-					if(array_key_exists('img', $key)){
44
+				if ('class' == $key && is_array($key)) {
45
+					if (array_key_exists('img', $key)) {
46 46
 						$imgClass = $key['img'];
47
-					}else if(array_key_exists('input', $key)){
47
+					}else if (array_key_exists('input', $key)) {
48 48
 						$inputClass = $key['input'];
49 49
 					}
50
-				}else{
50
+				}else {
51 51
 					$imgClass = $inputClass = $key;
52 52
 				}
53 53
 			}
54
-			if(method_exists($this, $func)) {
54
+			if (method_exists($this, $func)) {
55 55
 				$response = $this->$key($length, $imgClass).$this->input($inputClass);
56
-			}else{
56
+			}else {
57 57
 				throw new Exception("Error Processing Captcha Method", 1);
58 58
 			}
59
-		}else if(is_numeric($param)){
59
+		}else if (is_numeric($param)) {
60 60
 			$response = $this->img($param).$this->input();
61
-		}else{
61
+		}else {
62 62
 			throw new Exception("Error Processing Captcha Parameters", 1);
63 63
 		}
64 64
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,21 +44,21 @@
 block discarded – undo
44 44
 				if('class' == $key && is_array($key)) {
45 45
 					if(array_key_exists('img', $key)){
46 46
 						$imgClass = $key['img'];
47
-					}else if(array_key_exists('input', $key)){
47
+					} else if(array_key_exists('input', $key)){
48 48
 						$inputClass = $key['input'];
49 49
 					}
50
-				}else{
50
+				} else{
51 51
 					$imgClass = $inputClass = $key;
52 52
 				}
53 53
 			}
54 54
 			if(method_exists($this, $func)) {
55 55
 				$response = $this->$key($length, $imgClass).$this->input($inputClass);
56
-			}else{
56
+			} else{
57 57
 				throw new Exception("Error Processing Captcha Method", 1);
58 58
 			}
59
-		}else if(is_numeric($param)){
59
+		} else if(is_numeric($param)){
60 60
 			$response = $this->img($param).$this->input();
61
-		}else{
61
+		} else{
62 62
 			throw new Exception("Error Processing Captcha Parameters", 1);
63 63
 		}
64 64
 
Please login to merge, or discard this patch.
helpers/Model.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 		);
20 20
 
21 21
 	public function __construct() {
22
-		if(property_exists($this, 'fields')) {
22
+		if (property_exists($this, 'fields')) {
23 23
 			$this->fieldConf = array_merge($this->fields, $this->fieldConf);
24 24
 		}
25 25
 
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 
31 31
 	private function validate($caller, $parent) {
32 32
 		$valid = true;
33
-		foreach($this->getFieldConfiguration() as $field => $conf) {
34
-			if(isset($conf['type']) && !isset($conf['relType'])){
33
+		foreach ($this->getFieldConfiguration() as $field => $conf) {
34
+			if (isset($conf['type']) && !isset($conf['relType'])) {
35 35
 				$val = $this->get($field);
36
-				$model = strtolower(str_replace('\\','.',$class));
36
+				$model = strtolower(str_replace('\\', '.', $class));
37 37
 				// check required fields
38 38
 				if ($valid && isset($conf['required']))
39
-					$valid = \Validation::instance()->required($val,$field,'error.'.$model.'.'.$field);
39
+					$valid = \Validation::instance()->required($val, $field, 'error.'.$model.'.'.$field);
40 40
 				// check unique
41 41
 				if ($valid && isset($conf['unique']))
42
-					$valid = \Validation::instance()->unique($self,$val,$field,'error.'.$model.'.'.$field);
42
+					$valid = \Validation::instance()->unique($self, $val, $field, 'error.'.$model.'.'.$field);
43 43
 				if (!$valid)
44 44
 					break;
45 45
 			}
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,13 +35,16 @@
 block discarded – undo
35 35
 				$val = $this->get($field);
36 36
 				$model = strtolower(str_replace('\\','.',$class));
37 37
 				// check required fields
38
-				if ($valid && isset($conf['required']))
39
-					$valid = \Validation::instance()->required($val,$field,'error.'.$model.'.'.$field);
38
+				if ($valid && isset($conf['required'])) {
39
+									$valid = \Validation::instance()->required($val,$field,'error.'.$model.'.'.$field);
40
+				}
40 41
 				// check unique
41
-				if ($valid && isset($conf['unique']))
42
-					$valid = \Validation::instance()->unique($self,$val,$field,'error.'.$model.'.'.$field);
43
-				if (!$valid)
44
-					break;
42
+				if ($valid && isset($conf['unique'])) {
43
+									$valid = \Validation::instance()->unique($self,$val,$field,'error.'.$model.'.'.$field);
44
+				}
45
+				if (!$valid) {
46
+									break;
47
+				}
45 48
 			}
46 49
 		}
47 50
 		return $valid;
Please login to merge, or discard this patch.
helpers/Str.php 2 patches
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -2,233 +2,233 @@
 block discarded – undo
2 2
 
3 3
 class Str extends Prefab {
4 4
 	protected static $snakeCache = [];
5
-    protected static $camelCache = [];
6
-    protected static $studlyCache = [];
5
+	protected static $camelCache = [];
6
+	protected static $studlyCache = [];
7 7
 	
8 8
 	public static function after($subject, $search) {
9
-        return $search === '' ? $subject : array_reverse(explode($search, $subject, 2))[0];
10
-    }
9
+		return $search === '' ? $subject : array_reverse(explode($search, $subject, 2))[0];
10
+	}
11 11
 
12
-    public static function before($subject, $search) {
13
-        return $search === '' ? $subject : explode($search, $subject)[0];
14
-    }
12
+	public static function before($subject, $search) {
13
+		return $search === '' ? $subject : explode($search, $subject)[0];
14
+	}
15 15
 
16
-    public static function camel($value) {
17
-        if (isset(static::$camelCache[$value])) {
18
-            return static::$camelCache[$value];
19
-        }
16
+	public static function camel($value) {
17
+		if (isset(static::$camelCache[$value])) {
18
+			return static::$camelCache[$value];
19
+		}
20 20
 
21
-        return static::$camelCache[$value] = lcfirst(static::studly($value));
22
-    }
21
+		return static::$camelCache[$value] = lcfirst(static::studly($value));
22
+	}
23 23
 
24
-    public static function contains($haystack, $needles) {
25
-        foreach ((array) $needles as $needle) {
26
-            if ($needle !== '' && mb_strpos($haystack, $needle) !== false) {
27
-                return true;
28
-            }
29
-        }
24
+	public static function contains($haystack, $needles) {
25
+		foreach ((array) $needles as $needle) {
26
+			if ($needle !== '' && mb_strpos($haystack, $needle) !== false) {
27
+				return true;
28
+			}
29
+		}
30 30
 
31
-        return false;
32
-    }
31
+		return false;
32
+	}
33 33
 
34
-    public static function endsWith($haystack, $needles) {
35
-        foreach ((array) $needles as $needle) {
36
-            if (substr($haystack, -strlen($needle)) === (string) $needle) {
37
-                return true;
38
-            }
39
-        }
34
+	public static function endsWith($haystack, $needles) {
35
+		foreach ((array) $needles as $needle) {
36
+			if (substr($haystack, -strlen($needle)) === (string) $needle) {
37
+				return true;
38
+			}
39
+		}
40 40
 
41
-        return false;
42
-    }
41
+		return false;
42
+	}
43 43
 
44
-    public static function finish($value, $cap) {
45
-        $quoted = preg_quote($cap, '/');
44
+	public static function finish($value, $cap) {
45
+		$quoted = preg_quote($cap, '/');
46 46
 
47
-        return preg_replace('/(?:'.$quoted.')+$/u', '', $value).$cap;
48
-    }
47
+		return preg_replace('/(?:'.$quoted.')+$/u', '', $value).$cap;
48
+	}
49 49
 
50
-    public static function is($pattern, $value) {
51
-        $patterns = is_array($pattern) ? $pattern : (array) $pattern;
50
+	public static function is($pattern, $value) {
51
+		$patterns = is_array($pattern) ? $pattern : (array) $pattern;
52 52
 
53
-        if (empty($patterns)) {
54
-            return false;
55
-        }
53
+		if (empty($patterns)) {
54
+			return false;
55
+		}
56 56
 
57
-        foreach ($patterns as $pattern) {
58
-            if ($pattern == $value) {
59
-                return true;
60
-            }
57
+		foreach ($patterns as $pattern) {
58
+			if ($pattern == $value) {
59
+				return true;
60
+			}
61 61
 
62
-            $pattern = preg_quote($pattern, '#');
63
-            $pattern = str_replace('\*', '.*', $pattern);
62
+			$pattern = preg_quote($pattern, '#');
63
+			$pattern = str_replace('\*', '.*', $pattern);
64 64
 
65
-            if (preg_match('#^'.$pattern.'\z#u', $value) === 1) {
66
-                return true;
67
-            }
68
-        }
65
+			if (preg_match('#^'.$pattern.'\z#u', $value) === 1) {
66
+				return true;
67
+			}
68
+		}
69 69
 
70
-        return false;
71
-    }
70
+		return false;
71
+	}
72 72
 
73
-    public static function kebab($value) {
74
-        return static::snake($value, '-');
75
-    }
73
+	public static function kebab($value) {
74
+		return static::snake($value, '-');
75
+	}
76 76
 
77
-    public static function length($value, $encoding = null) {
78
-        if ($encoding) {
79
-            return mb_strlen($value, $encoding);
80
-        }
77
+	public static function length($value, $encoding = null) {
78
+		if ($encoding) {
79
+			return mb_strlen($value, $encoding);
80
+		}
81 81
 
82
-        return mb_strlen($value);
83
-    }
82
+		return mb_strlen($value);
83
+	}
84 84
 
85
-    public static function limit($value, $limit = 100, $end = '...') {
86
-        if (mb_strwidth($value, 'UTF-8') <= $limit) {
87
-            return $value;
88
-        }
85
+	public static function limit($value, $limit = 100, $end = '...') {
86
+		if (mb_strwidth($value, 'UTF-8') <= $limit) {
87
+			return $value;
88
+		}
89 89
 
90
-        return rtrim(mb_strimwidth($value, 0, $limit, '', 'UTF-8')).$end;
91
-    }
90
+		return rtrim(mb_strimwidth($value, 0, $limit, '', 'UTF-8')).$end;
91
+	}
92 92
 
93
-    public static function lower($value) {
94
-        return mb_strtolower($value, 'UTF-8');
95
-    }
93
+	public static function lower($value) {
94
+		return mb_strtolower($value, 'UTF-8');
95
+	}
96 96
 
97
-    public static function words($value, $words = 100, $end = '...') {
98
-        preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches);
97
+	public static function words($value, $words = 100, $end = '...') {
98
+		preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches);
99 99
 
100
-        if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) {
101
-            return $value;
102
-        }
100
+		if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) {
101
+			return $value;
102
+		}
103 103
 
104
-        return rtrim($matches[0]).$end;
105
-    }
104
+		return rtrim($matches[0]).$end;
105
+	}
106 106
 
107
-    public static function parseCallback($callback, $default = null) {
108
-        return static::contains($callback, '@') ? explode('@', $callback, 2) : [$callback, $default];
109
-    }
107
+	public static function parseCallback($callback, $default = null) {
108
+		return static::contains($callback, '@') ? explode('@', $callback, 2) : [$callback, $default];
109
+	}
110 110
 
111
-    public static function plural($value, $count = 2) {
112
-        return Pluralizer::plural($value, $count);
113
-    }
111
+	public static function plural($value, $count = 2) {
112
+		return Pluralizer::plural($value, $count);
113
+	}
114 114
 
115
-    public static function random($length = 16) {
116
-        $string = '';
115
+	public static function random($length = 16) {
116
+		$string = '';
117 117
 
118
-        while (($len = strlen($string)) < $length) {
119
-            $size = $length - $len;
120
-            $bytes = random_bytes($size);
121
-            $string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
122
-        }
118
+		while (($len = strlen($string)) < $length) {
119
+			$size = $length - $len;
120
+			$bytes = random_bytes($size);
121
+			$string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
122
+		}
123 123
 
124
-        return $string;
125
-    }
124
+		return $string;
125
+	}
126 126
 
127
-    public static function replaceArray($search, array $replace, $subject) {
128
-        foreach ($replace as $value) {
129
-            $subject = static::replaceFirst($search, $value, $subject);
130
-        }
127
+	public static function replaceArray($search, array $replace, $subject) {
128
+		foreach ($replace as $value) {
129
+			$subject = static::replaceFirst($search, $value, $subject);
130
+		}
131 131
 
132
-        return $subject;
133
-    }
132
+		return $subject;
133
+	}
134 134
 
135
-    public static function replaceFirst($search, $replace, $subject) {
136
-        if ($search == '') {
137
-            return $subject;
138
-        }
135
+	public static function replaceFirst($search, $replace, $subject) {
136
+		if ($search == '') {
137
+			return $subject;
138
+		}
139 139
 
140
-        $position = strpos($subject, $search);
140
+		$position = strpos($subject, $search);
141 141
 
142
-        if ($position !== false) {
143
-            return substr_replace($subject, $replace, $position, strlen($search));
144
-        }
142
+		if ($position !== false) {
143
+			return substr_replace($subject, $replace, $position, strlen($search));
144
+		}
145 145
 
146
-        return $subject;
147
-    }
146
+		return $subject;
147
+	}
148 148
 
149
-    public static function replaceLast($search, $replace, $subject) {
150
-        $position = strrpos($subject, $search);
149
+	public static function replaceLast($search, $replace, $subject) {
150
+		$position = strrpos($subject, $search);
151 151
 
152
-        if ($position !== false) {
153
-            return substr_replace($subject, $replace, $position, strlen($search));
154
-        }
152
+		if ($position !== false) {
153
+			return substr_replace($subject, $replace, $position, strlen($search));
154
+		}
155 155
 
156
-        return $subject;
157
-    }
156
+		return $subject;
157
+	}
158 158
 
159
-    public static function start($value, $prefix) {
160
-        $quoted = preg_quote($prefix, '/');
161
-        return $prefix.preg_replace('/^(?:'.$quoted.')+/u', '', $value);
162
-    }
159
+	public static function start($value, $prefix) {
160
+		$quoted = preg_quote($prefix, '/');
161
+		return $prefix.preg_replace('/^(?:'.$quoted.')+/u', '', $value);
162
+	}
163 163
 
164
-    public static function upper($value) {
165
-        return mb_strtoupper($value, 'UTF-8');
166
-    }
164
+	public static function upper($value) {
165
+		return mb_strtoupper($value, 'UTF-8');
166
+	}
167 167
 
168
-    public static function title($value) {
169
-        return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8');
170
-    }
168
+	public static function title($value) {
169
+		return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8');
170
+	}
171 171
 
172
-    public static function singular($value) {
173
-        return Pluralizer::singular($value);
174
-    }
172
+	public static function singular($value) {
173
+		return Pluralizer::singular($value);
174
+	}
175 175
 
176
-    public static function slug($title, $separator = '-', $language = 'en') {
177
-        $title = static::ascii($title, $language);
176
+	public static function slug($title, $separator = '-', $language = 'en') {
177
+		$title = static::ascii($title, $language);
178 178
 
179
-        $flip = $separator == '-' ? '_' : '-';
179
+		$flip = $separator == '-' ? '_' : '-';
180 180
 
181
-        $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);
182
-        $title = str_replace('@', $separator.'at'.$separator, $title);
183
-        $title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title));
184
-        $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title);
181
+		$title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);
182
+		$title = str_replace('@', $separator.'at'.$separator, $title);
183
+		$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title));
184
+		$title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title);
185 185
 
186
-        return trim($title, $separator);
187
-    }
186
+		return trim($title, $separator);
187
+	}
188 188
 
189
-    public static function snake($value, $delimiter = '_') {
190
-        $key = $value;
189
+	public static function snake($value, $delimiter = '_') {
190
+		$key = $value;
191 191
 
192
-        if (isset(static::$snakeCache[$key][$delimiter])) {
193
-            return static::$snakeCache[$key][$delimiter];
194
-        }
192
+		if (isset(static::$snakeCache[$key][$delimiter])) {
193
+			return static::$snakeCache[$key][$delimiter];
194
+		}
195 195
 
196
-        if (! ctype_lower($value)) {
197
-            $value = preg_replace('/\s+/u', '', ucwords($value));
196
+		if (! ctype_lower($value)) {
197
+			$value = preg_replace('/\s+/u', '', ucwords($value));
198 198
 
199
-            $value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value));
200
-        }
199
+			$value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value));
200
+		}
201 201
 
202
-        return static::$snakeCache[$key][$delimiter] = $value;
203
-    }
202
+		return static::$snakeCache[$key][$delimiter] = $value;
203
+	}
204 204
 
205
-    public static function startsWith($haystack, $needles) {
206
-        foreach ((array) $needles as $needle) {
207
-            if ($needle !== '' && substr($haystack, 0, strlen($needle)) === (string) $needle) {
208
-                return true;
209
-            }
210
-        }
205
+	public static function startsWith($haystack, $needles) {
206
+		foreach ((array) $needles as $needle) {
207
+			if ($needle !== '' && substr($haystack, 0, strlen($needle)) === (string) $needle) {
208
+				return true;
209
+			}
210
+		}
211 211
 
212
-        return false;
213
-    }
212
+		return false;
213
+	}
214 214
 
215
-    public static function studly($value) {
216
-        $key = $value;
215
+	public static function studly($value) {
216
+		$key = $value;
217 217
 
218
-        if (isset(static::$studlyCache[$key])) {
219
-            return static::$studlyCache[$key];
220
-        }
218
+		if (isset(static::$studlyCache[$key])) {
219
+			return static::$studlyCache[$key];
220
+		}
221 221
 
222
-        $value = ucwords(str_replace(['-', '_'], ' ', $value));
222
+		$value = ucwords(str_replace(['-', '_'], ' ', $value));
223 223
 
224
-        return static::$studlyCache[$key] = str_replace(' ', '', $value);
225
-    }
224
+		return static::$studlyCache[$key] = str_replace(' ', '', $value);
225
+	}
226 226
 
227
-    public static function substr($string, $start, $length = null) {
228
-        return mb_substr($string, $start, $length, 'UTF-8');
229
-    }
227
+	public static function substr($string, $start, $length = null) {
228
+		return mb_substr($string, $start, $length, 'UTF-8');
229
+	}
230 230
 
231
-    public static function ucfirst($string) {
232
-        return static::upper(static::substr($string, 0, 1)).static::substr($string, 1);
233
-    }
231
+	public static function ucfirst($string) {
232
+		return static::upper(static::substr($string, 0, 1)).static::substr($string, 1);
233
+	}
234 234
 }
235 235
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     public static function words($value, $words = 100, $end = '...') {
98 98
         preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches);
99 99
 
100
-        if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) {
100
+        if (!isset($matches[0]) || static::length($value) === static::length($matches[0])) {
101 101
             return $value;
102 102
         }
103 103
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
             return static::$snakeCache[$key][$delimiter];
194 194
         }
195 195
 
196
-        if (! ctype_lower($value)) {
196
+        if (!ctype_lower($value)) {
197 197
             $value = preg_replace('/\s+/u', '', ucwords($value));
198 198
 
199 199
             $value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value));
Please login to merge, or discard this patch.
bootstrap/helpers.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function f3($get=null){$f3=Base::instance();return $get?$f3->get($get):$f3;}
3
+function f3($get = null) {$f3 = Base::instance(); return $get ? $f3->get($get) : $f3; }
4 4
 
5
-function base_path($inner = ''){return realpath(__DIR__.'/../').'/'.$inner;}
6
-function storage_path($inner = ''){return base_path('storage/').'/'.$inner;}
7
-function db_path($db = ''){return storage_path('db/').$db;}
8
-function lang_path($lang = ''){return base_path('resources/lang/').'/'.$lang;}
9
-function views_path(){return base_path('resources/views/');}
10
-function config_path($config = ''){return base_path('config/').'/'.$config;}
5
+function base_path($inner = '') {return realpath(__DIR__.'/../').'/'.$inner; }
6
+function storage_path($inner = '') {return base_path('storage/').'/'.$inner; }
7
+function db_path($db = '') {return storage_path('db/').$db; }
8
+function lang_path($lang = '') {return base_path('resources/lang/').'/'.$lang; }
9
+function views_path() {return base_path('resources/views/'); }
10
+function config_path($config = '') {return base_path('config/').'/'.$config; }
11 11
 
12
-function abort(){f3()->abort();}
13
-function status($code=404){f3()->error($code);}
14
-function reroute($where){f3()->reroute($where);}
15
-function is_api($path){if(is_string($path)) {return explode('/', $path)[1] === 'api';}return false;}
12
+function abort() {f3()->abort(); }
13
+function status($code = 404) {f3()->error($code); }
14
+function reroute($where) {f3()->reroute($where); }
15
+function is_api($path) {if (is_string($path)) {return explode('/', $path)[1] === 'api'; }return false; }
16 16
 
17 17
 function view($template, array $params = [], $mime = 'text/html') {
18
-	if(!empty($params)) {
18
+	if (!empty($params)) {
19 19
 		f3()->mset($params);
20 20
 	}
21
-	if(is_array($template)){
21
+	if (is_array($template)) {
22 22
 		$layout = $template[0];
23 23
 		$view = $template[1];
24
-	}else{
24
+	}else {
25 25
 		$layout = 'layouts/app.htm';
26 26
 		$view = $template;
27 27
 	}
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
 
32 32
 function template($template, array $params = [], $mime = 'text/html') {
33 33
 	$f3 = f3();
34
-	if(!empty($params)) {
34
+	if (!empty($params)) {
35 35
 		$f3->mset($params);
36 36
 	}
37
-	if(is_array($template)){
37
+	if (is_array($template)) {
38 38
 		$layout = $template[0];
39 39
 		$view = $template[1];
40
-	}else{
40
+	}else {
41 41
 		$layout = 'layouts/app.htm';
42 42
 		$view = $template;
43 43
 	}
@@ -46,23 +46,23 @@  discard block
 block discarded – undo
46 46
 	echo Template::instance()->render($layout, $mime);
47 47
 }
48 48
 
49
-function str_contains($haystack,$needles){foreach((array)$needles as $needle){if($needle!=''&&mb_strpos($haystack,$needle)!==false){return true;}}return false;}
50
-function extension($file,$default='json'){return $file.'.'.(pathinfo($file,PATHINFO_EXTENSION)?:$default);}
51
-function flash($message, $type = 'success') {Flash::instance()->addMessage($message, $type);}
52
-function trans($key,$params=null){return f3()->format(f3()->get($key),($params?:''));}
49
+function str_contains($haystack, $needles) {foreach ((array) $needles as $needle) {if ($needle != '' && mb_strpos($haystack, $needle) !== false) {return true; }}return false; }
50
+function extension($file, $default = 'json') {return $file.'.'.(pathinfo($file, PATHINFO_EXTENSION) ?: $default); }
51
+function flash($message, $type = 'success') {Flash::instance()->addMessage($message, $type); }
52
+function trans($key, $params = null) {return f3()->format(f3()->get($key), ($params ?: '')); }
53 53
 function error($error) {
54
-	if(null === $error) {return;}
55
-	if(is_array($error)) {
56
-		foreach($error as $err) {
57
-			if(is_array($err)) {
58
-				foreach($err as $e) {
54
+	if (null === $error) {return; }
55
+	if (is_array($error)) {
56
+		foreach ($error as $err) {
57
+			if (is_array($err)) {
58
+				foreach ($err as $e) {
59 59
 					flash($e, 'danger');
60 60
 				}
61
-			}else{
61
+			}else {
62 62
 				flash($err, 'danger');
63 63
 			}
64 64
 		}
65
-	}else{
65
+	}else {
66 66
 		flash($error, 'danger');
67 67
 	}
68 68
 }
69 69
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	if(is_array($template)){
22 22
 		$layout = $template[0];
23 23
 		$view = $template[1];
24
-	}else{
24
+	} else{
25 25
 		$layout = 'layouts/app.htm';
26 26
 		$view = $template;
27 27
 	}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	if(is_array($template)){
38 38
 		$layout = $template[0];
39 39
 		$view = $template[1];
40
-	}else{
40
+	} else{
41 41
 		$layout = 'layouts/app.htm';
42 42
 		$view = $template;
43 43
 	}
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 				foreach($err as $e) {
59 59
 					flash($e, 'danger');
60 60
 				}
61
-			}else{
61
+			} else{
62 62
 				flash($err, 'danger');
63 63
 			}
64 64
 		}
65
-	}else{
65
+	} else{
66 66
 		flash($error, 'danger');
67 67
 	}
68 68
 }
69 69
\ No newline at end of file
Please login to merge, or discard this patch.