Passed
Branch master (e24a60)
by Anu
02:47
created
helpers/Controller.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,14 +2,14 @@
 block discarded – undo
2 2
 
3 3
 abstract class Controller
4 4
 {
5
-    protected $viewPath;
5
+	protected $viewPath;
6 6
 
7
-    protected function view()
8
-    {
9
-    }
7
+	protected function view()
8
+	{
9
+	}
10 10
 
11
-    protected function template($template)
12
-    {
13
-        template($this->viewPath.$template);
14
-    }
11
+	protected function template($template)
12
+	{
13
+		template($this->viewPath.$template);
14
+	}
15 15
 }
Please login to merge, or discard this patch.
helpers/Model.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -2,35 +2,35 @@
 block discarded – undo
2 2
 
3 3
 abstract class Model extends Cortex
4 4
 {
5
-    protected $app;
6
-    protected $db = 'DB';
7
-    protected $fieldConf = array(
8
-        'created_at' => array(
9
-            'type' => Schema::DT_TIMESTAMP,
10
-            'default' => Schema::DF_CURRENT_TIMESTAMP
11
-            ),
12
-        'updated_at' => array(
13
-            'type' => Schema::DT_TIMESTAMP,
14
-            'default' => '0-0-0 0:0:0'
15
-            ),
16
-        'deleted_at' => array(
17
-            'type' => Schema::DT_TIMESTAMP,
18
-            'default' => '0-0-0 0:0:0'
19
-            )
20
-        );
5
+	protected $app;
6
+	protected $db = 'DB';
7
+	protected $fieldConf = array(
8
+		'created_at' => array(
9
+			'type' => Schema::DT_TIMESTAMP,
10
+			'default' => Schema::DF_CURRENT_TIMESTAMP
11
+			),
12
+		'updated_at' => array(
13
+			'type' => Schema::DT_TIMESTAMP,
14
+			'default' => '0-0-0 0:0:0'
15
+			),
16
+		'deleted_at' => array(
17
+			'type' => Schema::DT_TIMESTAMP,
18
+			'default' => '0-0-0 0:0:0'
19
+			)
20
+		);
21 21
 
22
-    public function __construct()
23
-    {
24
-        if (property_exists($this, 'fields')) {
25
-            $this->fieldConf = array_merge($this->fields, $this->fieldConf);
26
-        }
22
+	public function __construct()
23
+	{
24
+		if (property_exists($this, 'fields')) {
25
+			$this->fieldConf = array_merge($this->fields, $this->fieldConf);
26
+		}
27 27
 
28
-        parent::__construct();
29
-        $this->app = f3();
30
-        //$this->beforesave($this->validate(get_called_class()));
31
-    }
28
+		parent::__construct();
29
+		$this->app = f3();
30
+		//$this->beforesave($this->validate(get_called_class()));
31
+	}
32 32
 
33
-    /*private function validate($caller, $parent) {
33
+	/*private function validate($caller, $parent) {
34 34
         $valid = true;
35 35
         foreach($this->getFieldConfiguration() as $field => $conf) {
36 36
             if(isset($conf['type']) && !isset($conf['relType'])){
Please login to merge, or discard this patch.
helpers/Route.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -2,88 +2,88 @@
 block discarded – undo
2 2
 
3 3
 class Route extends Prefab
4 4
 {
5
-    private $app;
6
-
7
-    public function __construct()
8
-    {
9
-        if ($this->app == null) {
10
-            $this->app = f3();
11
-        }
12
-    }
13
-
14
-    public function uri()
15
-    {
16
-        return $this->app['URI'];
17
-    }
18
-
19
-    public function type()
20
-    {
21
-        return $this->app['VERB'];
22
-    }
23
-
24
-    public function has($route)
25
-    {
26
-        if (str_contains($route, '/')) {
27
-            return array_key_exists($route, $this->getRoutes());
28
-        }
29
-
30
-        return $this->getNamedRoute($route);
31
-    }
32
-
33
-    public function current()
34
-    {
35
-        return $this->app['PATH'];
36
-    }
37
-
38
-    public function is($route)
39
-    {
40
-        return Str::contains($this->current(), $route);
41
-    }
42
-
43
-    public function currentRouteName()
44
-    {
45
-        return $this->getRoutes()[$this->current()][0][$this->type()][3];
46
-    }
47
-
48
-    public function getRouteName($route)
49
-    {
50
-        $response = null;
51
-        foreach ($this->getNamedRoutes() as $name => $url) {
52
-            if ($url == $route) {
53
-                $response[] = $name;
54
-            }
55
-        }
56
-        return $response;
57
-        //return array_search($this->getNamedRoutes(), $route);
58
-    }
59
-
60
-    public function getNamedRoute($route)
61
-    {
62
-        return array_key_exists($route, $this->getNamedRoutes());
63
-    }
64
-
65
-    public function getNamedRoutes()
66
-    {
67
-        return $this->app['ALIASES'];
68
-    }
69
-
70
-    public function getRoutes()
71
-    {
72
-        return $this->app['ROUTES'];
73
-    }
74
-
75
-    public function hasParameter($parameter)
76
-    {
77
-        return (bool) $this->parameter($parameter);
78
-    }
79
-
80
-    public function parameters()
81
-    {
82
-        return $this->app[$this->type()];
83
-    }
84
-
85
-    public function parameter($parameter)
86
-    {
87
-        return $this->app[$this->type().'.'.$parameter];
88
-    }
5
+	private $app;
6
+
7
+	public function __construct()
8
+	{
9
+		if ($this->app == null) {
10
+			$this->app = f3();
11
+		}
12
+	}
13
+
14
+	public function uri()
15
+	{
16
+		return $this->app['URI'];
17
+	}
18
+
19
+	public function type()
20
+	{
21
+		return $this->app['VERB'];
22
+	}
23
+
24
+	public function has($route)
25
+	{
26
+		if (str_contains($route, '/')) {
27
+			return array_key_exists($route, $this->getRoutes());
28
+		}
29
+
30
+		return $this->getNamedRoute($route);
31
+	}
32
+
33
+	public function current()
34
+	{
35
+		return $this->app['PATH'];
36
+	}
37
+
38
+	public function is($route)
39
+	{
40
+		return Str::contains($this->current(), $route);
41
+	}
42
+
43
+	public function currentRouteName()
44
+	{
45
+		return $this->getRoutes()[$this->current()][0][$this->type()][3];
46
+	}
47
+
48
+	public function getRouteName($route)
49
+	{
50
+		$response = null;
51
+		foreach ($this->getNamedRoutes() as $name => $url) {
52
+			if ($url == $route) {
53
+				$response[] = $name;
54
+			}
55
+		}
56
+		return $response;
57
+		//return array_search($this->getNamedRoutes(), $route);
58
+	}
59
+
60
+	public function getNamedRoute($route)
61
+	{
62
+		return array_key_exists($route, $this->getNamedRoutes());
63
+	}
64
+
65
+	public function getNamedRoutes()
66
+	{
67
+		return $this->app['ALIASES'];
68
+	}
69
+
70
+	public function getRoutes()
71
+	{
72
+		return $this->app['ROUTES'];
73
+	}
74
+
75
+	public function hasParameter($parameter)
76
+	{
77
+		return (bool) $this->parameter($parameter);
78
+	}
79
+
80
+	public function parameters()
81
+	{
82
+		return $this->app[$this->type()];
83
+	}
84
+
85
+	public function parameter($parameter)
86
+	{
87
+		return $this->app[$this->type().'.'.$parameter];
88
+	}
89 89
 }
Please login to merge, or discard this patch.
helpers/Captcha.php 2 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -2,123 +2,123 @@
 block discarded – undo
2 2
 
3 3
 class Captcha extends Prefab
4 4
 {
5
-    protected $name;
6
-    protected $code;
7
-    protected $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
8
-
9
-    public function __construct($name = 'captcha-string')
10
-    {
11
-        $this->name = $name;
12
-    }
13
-
14
-    public function text($length = 4, $mock = null)
15
-    {
16
-        $this->setSession($code = $this->_generate($length));
17
-        return $code;
18
-    }
19
-
20
-    public function img($length = 4, $class = 'captcha-img')
21
-    {
22
-        return '<img src="'.$this->text($length).'" class="'.$class.'" />';
23
-    }
24
-
25
-    public function source($length = 4, $mock = null)
26
-    {
27
-    }
28
-
29
-    public function input($class = 'captcha-input')
30
-    {
31
-        return '<input type="text" class="'.$class.'" name="'.$this->name.'" />';
32
-    }
33
-
34
-    /*
5
+	protected $name;
6
+	protected $code;
7
+	protected $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
8
+
9
+	public function __construct($name = 'captcha-string')
10
+	{
11
+		$this->name = $name;
12
+	}
13
+
14
+	public function text($length = 4, $mock = null)
15
+	{
16
+		$this->setSession($code = $this->_generate($length));
17
+		return $code;
18
+	}
19
+
20
+	public function img($length = 4, $class = 'captcha-img')
21
+	{
22
+		return '<img src="'.$this->text($length).'" class="'.$class.'" />';
23
+	}
24
+
25
+	public function source($length = 4, $mock = null)
26
+	{
27
+	}
28
+
29
+	public function input($class = 'captcha-input')
30
+	{
31
+		return '<input type="text" class="'.$class.'" name="'.$this->name.'" />';
32
+	}
33
+
34
+	/*
35 35
     * Captcha::instance()->render(4)
36 36
     * Captcha::instance()->render(array('type'=>'img','length'=>4,'class'=>array('img'=>'captcha-img','input'=>'captcha-input')));
37 37
      */
38
-    public function render($param, $url)
39
-    {
40
-        if (is_array($param)) {
41
-            $func = null;
42
-            $length = null;
43
-            $imgClass = null;
44
-            $inputClass = null;
45
-            foreach ($param as $key => $val) {
46
-                if ('type' == $key) {
47
-                    $func = $key;
48
-                }
49
-                if ('length' == $key) {
50
-                    $length = $key;
51
-                }
52
-                if ('class' == $key && is_array($key)) {
53
-                    if (array_key_exists('img', $key)) {
54
-                        $imgClass = $key['img'];
55
-                    } elseif (array_key_exists('input', $key)) {
56
-                        $inputClass = $key['input'];
57
-                    }
58
-                } else {
59
-                    $imgClass = $inputClass = $key;
60
-                }
61
-            }
62
-            if (method_exists($this, $func)) {
63
-                $response = $this->$key($length, $imgClass).$this->input($inputClass);
64
-            } else {
65
-                throw new Exception("Error Processing Captcha Method", 1);
66
-            }
67
-        } elseif (is_numeric($param)) {
68
-            $response = $this->img($param).$this->input();
69
-        } else {
70
-            throw new Exception("Error Processing Captcha Parameters", 1);
71
-        }
72
-
73
-        return '<form method="post" action="'.$url.'">'.$response.'</form>';
74
-    }
75
-
76
-    public function name($name)
77
-    {
78
-        $this->name = $name;
79
-        return $this;
80
-    }
81
-
82
-    public function verify($code)
83
-    {
84
-        $this->startSession();
85
-
86
-        $n = $this->name;
87
-
88
-        $valid = isset($_SESSION[$n])
89
-            && isset($_POST[$n])
90
-            && strlen($_POST[$n])
91
-            && ($_SESSION[$n] === crypt(strtolower($_POST[$n]), $this->salt()));
92
-
93
-        if (isset($_POST[$n])) {
94
-            unset($_POST[$n]);
95
-        }
96
-
97
-        if ($valid && isset($_SESSION[$n])) {
98
-            unset($_SESSION[$n]);
99
-        }
100
-
101
-        return $valid;
102
-    }
103
-
104
-    private function startSession()
105
-    {
106
-        session_id() || session_start();
107
-    }
108
-
109
-    private function setSession($string)
110
-    {
111
-        $this->startSession();
112
-        $_SESSION[$this->name] = crypt(strtolower($string), $this->salt());
113
-    }
114
-
115
-    private function _generate($length)
116
-    {
117
-        return $this->code = substr(str_shuffle(str_repeat($this->pool, 5)), 0, $length);
118
-    }
119
-
120
-    private static function salt()
121
-    {
122
-        return md5(__FILE__.filemtime(__FILE__));
123
-    }
38
+	public function render($param, $url)
39
+	{
40
+		if (is_array($param)) {
41
+			$func = null;
42
+			$length = null;
43
+			$imgClass = null;
44
+			$inputClass = null;
45
+			foreach ($param as $key => $val) {
46
+				if ('type' == $key) {
47
+					$func = $key;
48
+				}
49
+				if ('length' == $key) {
50
+					$length = $key;
51
+				}
52
+				if ('class' == $key && is_array($key)) {
53
+					if (array_key_exists('img', $key)) {
54
+						$imgClass = $key['img'];
55
+					} elseif (array_key_exists('input', $key)) {
56
+						$inputClass = $key['input'];
57
+					}
58
+				} else {
59
+					$imgClass = $inputClass = $key;
60
+				}
61
+			}
62
+			if (method_exists($this, $func)) {
63
+				$response = $this->$key($length, $imgClass).$this->input($inputClass);
64
+			} else {
65
+				throw new Exception("Error Processing Captcha Method", 1);
66
+			}
67
+		} elseif (is_numeric($param)) {
68
+			$response = $this->img($param).$this->input();
69
+		} else {
70
+			throw new Exception("Error Processing Captcha Parameters", 1);
71
+		}
72
+
73
+		return '<form method="post" action="'.$url.'">'.$response.'</form>';
74
+	}
75
+
76
+	public function name($name)
77
+	{
78
+		$this->name = $name;
79
+		return $this;
80
+	}
81
+
82
+	public function verify($code)
83
+	{
84
+		$this->startSession();
85
+
86
+		$n = $this->name;
87
+
88
+		$valid = isset($_SESSION[$n])
89
+			&& isset($_POST[$n])
90
+			&& strlen($_POST[$n])
91
+			&& ($_SESSION[$n] === crypt(strtolower($_POST[$n]), $this->salt()));
92
+
93
+		if (isset($_POST[$n])) {
94
+			unset($_POST[$n]);
95
+		}
96
+
97
+		if ($valid && isset($_SESSION[$n])) {
98
+			unset($_SESSION[$n]);
99
+		}
100
+
101
+		return $valid;
102
+	}
103
+
104
+	private function startSession()
105
+	{
106
+		session_id() || session_start();
107
+	}
108
+
109
+	private function setSession($string)
110
+	{
111
+		$this->startSession();
112
+		$_SESSION[$this->name] = crypt(strtolower($string), $this->salt());
113
+	}
114
+
115
+	private function _generate($length)
116
+	{
117
+		return $this->code = substr(str_shuffle(str_repeat($this->pool, 5)), 0, $length);
118
+	}
119
+
120
+	private static function salt()
121
+	{
122
+		return md5(__FILE__.filemtime(__FILE__));
123
+	}
124 124
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -55,18 +55,18 @@
 block discarded – undo
55 55
                     } elseif (array_key_exists('input', $key)) {
56 56
                         $inputClass = $key['input'];
57 57
                     }
58
-                } else {
58
+                }else {
59 59
                     $imgClass = $inputClass = $key;
60 60
                 }
61 61
             }
62 62
             if (method_exists($this, $func)) {
63 63
                 $response = $this->$key($length, $imgClass).$this->input($inputClass);
64
-            } else {
64
+            }else {
65 65
                 throw new Exception("Error Processing Captcha Method", 1);
66 66
             }
67 67
         } elseif (is_numeric($param)) {
68 68
             $response = $this->img($param).$this->input();
69
-        } else {
69
+        }else {
70 70
             throw new Exception("Error Processing Captcha Parameters", 1);
71 71
         }
72 72
 
Please login to merge, or discard this patch.
resources/lang/en.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -1,90 +1,90 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 return [
4
-    'site' => [
5
-        'title' => 'F3!',
6
-        'description' => 'description...',
7
-        'keywords' => 'f3, fatfree, fatfreeframework, anutig3r',
8
-        'author' => [
9
-            'name' => 'Anu Tig3r',
10
-            'email' => '[email protected]'
11
-        ]
12
-    ],
4
+	'site' => [
5
+		'title' => 'F3!',
6
+		'description' => 'description...',
7
+		'keywords' => 'f3, fatfree, fatfreeframework, anutig3r',
8
+		'author' => [
9
+			'name' => 'Anu Tig3r',
10
+			'email' => '[email protected]'
11
+		]
12
+	],
13 13
 
14
-    'error' => [
15
-        'validations' => [
16
-            'accepted' => 'The {0} must be accepted.',
17
-            'active_url' => 'The {0} is not a valid URL.',
18
-            'after' => 'The {0} must be a date after {1}.',
19
-            'after_or_equal' => 'The {0} must be a date after or equal to {1}.',
20
-            'alpha' => 'The {0} may only contain letters.',
21
-            'alpha_dash' => 'The {0} may only contain letters, numbers, and dashes.',
22
-            'alpha_num' => 'The {0} may only contain letters and numbers.',
23
-            'array' => 'The {0} must be an array.',
24
-            'before' => 'The {0} must be a date before {1}.',
25
-            'before_or_equal' => 'The {0} must be a date before or equal to {1}.',
26
-            'between' => [
27
-                'numeric' => 'The {0} must be between {1} and {2}.',
28
-                'file' => 'The {0} must be between {1} and {2} kilobytes.',
29
-                'string' => 'The {0} must be between {1} and {2} characters.',
30
-                'array' => 'The {0} must have between {1} and {2} items.',
31
-            ],
32
-            'boolean' => 'The {0} field must be true or false.',
33
-            'confirmed' => 'The {0} confirmation does not match.',
34
-            'date' => 'The {0} is not a valid date.',
35
-            'date_format' => 'The {0} does not match the format {1}.',
36
-            'digits' => 'The {0} must be :digits digits.',
37
-            'digits_between' => 'The {0} must be between {1} and {1} digits.',
38
-            'email' => 'The {0} must be a valid email address.',
39
-            'exists' => 'The selected {0} is invalid.',
40
-            'file' => 'The {0} must be a file.',
41
-            'filled' => 'The {0} field must have a value.',
42
-            'image' => 'The {0} must be an image.',
43
-            'in' => 'The selected {0} is invalid.',
44
-            'in_array' => 'The {0} field does not exist in {1}.',
45
-            'integer' => 'The {0} must be an integer.',
46
-            'ip' => 'The {0} must be a valid IP address.',
47
-            'ipv4' => 'The {0} must be a valid IPv4 address.',
48
-            'ipv6' => 'The {0} must be a valid IPv6 address.',
49
-            'json' => 'The {0} must be a valid JSON string.',
50
-            'max' => [
51
-                'numeric' => 'The {0} may not be greater than {1}.',
52
-                'file' => 'The {0} may not be greater than {1} kilobytes.',
53
-                'string' => 'The {0} may not be greater than {1} characters.',
54
-                'array' => 'The {0} may not have more than {1} items.',
55
-            ],
56
-            'mimes' => 'The {0} must be a file of {1} {2}.',
57
-            'mimetypes' => 'The {0} must be a file of {1} {2}.',
58
-            'min' => [
59
-                'numeric' => 'The {0} must be at least {1}.',
60
-                'file' => 'The {0} must be at least {1} kilobytes.',
61
-                'string' => 'The {0} must be at least {1} characters.',
62
-                'array' => 'The {0} must have at least {1} items.',
63
-            ],
64
-            'not_in' => 'The selected {0} is invalid.',
65
-            'numeric' => 'The {0} must be a number.',
66
-            'regex' => 'The {0} format is invalid.',
67
-            'required' => 'The {0} field is required.',
68
-            'same' => 'The {0} and {1} must match.',
69
-            'size' => [
70
-                'numeric' => 'The {0} must be {1}.',
71
-                'file' => 'The {0} must be {1} kilobytes.',
72
-                'string' => 'The {0} must be {1} characters.',
73
-                'array' => 'The {0} must contain {1} items.',
74
-            ],
75
-            'string' => 'The {0} must be a string.',
76
-            'timezone' => 'The {0} must be a valid zone.',
77
-            'unique' => 'The {0} has already been taken.',
78
-            'uploaded' => 'The {0} failed to upload.',
79
-            'url' => 'The {0} format is invalid.',
80
-        ],
81
-        'auth' => [
82
-            'not_registered' => '{0} is not registered with us!',
83
-            'password' => 'Password is not geniune for {0}',
84
-        ]
85
-    ],
14
+	'error' => [
15
+		'validations' => [
16
+			'accepted' => 'The {0} must be accepted.',
17
+			'active_url' => 'The {0} is not a valid URL.',
18
+			'after' => 'The {0} must be a date after {1}.',
19
+			'after_or_equal' => 'The {0} must be a date after or equal to {1}.',
20
+			'alpha' => 'The {0} may only contain letters.',
21
+			'alpha_dash' => 'The {0} may only contain letters, numbers, and dashes.',
22
+			'alpha_num' => 'The {0} may only contain letters and numbers.',
23
+			'array' => 'The {0} must be an array.',
24
+			'before' => 'The {0} must be a date before {1}.',
25
+			'before_or_equal' => 'The {0} must be a date before or equal to {1}.',
26
+			'between' => [
27
+				'numeric' => 'The {0} must be between {1} and {2}.',
28
+				'file' => 'The {0} must be between {1} and {2} kilobytes.',
29
+				'string' => 'The {0} must be between {1} and {2} characters.',
30
+				'array' => 'The {0} must have between {1} and {2} items.',
31
+			],
32
+			'boolean' => 'The {0} field must be true or false.',
33
+			'confirmed' => 'The {0} confirmation does not match.',
34
+			'date' => 'The {0} is not a valid date.',
35
+			'date_format' => 'The {0} does not match the format {1}.',
36
+			'digits' => 'The {0} must be :digits digits.',
37
+			'digits_between' => 'The {0} must be between {1} and {1} digits.',
38
+			'email' => 'The {0} must be a valid email address.',
39
+			'exists' => 'The selected {0} is invalid.',
40
+			'file' => 'The {0} must be a file.',
41
+			'filled' => 'The {0} field must have a value.',
42
+			'image' => 'The {0} must be an image.',
43
+			'in' => 'The selected {0} is invalid.',
44
+			'in_array' => 'The {0} field does not exist in {1}.',
45
+			'integer' => 'The {0} must be an integer.',
46
+			'ip' => 'The {0} must be a valid IP address.',
47
+			'ipv4' => 'The {0} must be a valid IPv4 address.',
48
+			'ipv6' => 'The {0} must be a valid IPv6 address.',
49
+			'json' => 'The {0} must be a valid JSON string.',
50
+			'max' => [
51
+				'numeric' => 'The {0} may not be greater than {1}.',
52
+				'file' => 'The {0} may not be greater than {1} kilobytes.',
53
+				'string' => 'The {0} may not be greater than {1} characters.',
54
+				'array' => 'The {0} may not have more than {1} items.',
55
+			],
56
+			'mimes' => 'The {0} must be a file of {1} {2}.',
57
+			'mimetypes' => 'The {0} must be a file of {1} {2}.',
58
+			'min' => [
59
+				'numeric' => 'The {0} must be at least {1}.',
60
+				'file' => 'The {0} must be at least {1} kilobytes.',
61
+				'string' => 'The {0} must be at least {1} characters.',
62
+				'array' => 'The {0} must have at least {1} items.',
63
+			],
64
+			'not_in' => 'The selected {0} is invalid.',
65
+			'numeric' => 'The {0} must be a number.',
66
+			'regex' => 'The {0} format is invalid.',
67
+			'required' => 'The {0} field is required.',
68
+			'same' => 'The {0} and {1} must match.',
69
+			'size' => [
70
+				'numeric' => 'The {0} must be {1}.',
71
+				'file' => 'The {0} must be {1} kilobytes.',
72
+				'string' => 'The {0} must be {1} characters.',
73
+				'array' => 'The {0} must contain {1} items.',
74
+			],
75
+			'string' => 'The {0} must be a string.',
76
+			'timezone' => 'The {0} must be a valid zone.',
77
+			'unique' => 'The {0} has already been taken.',
78
+			'uploaded' => 'The {0} failed to upload.',
79
+			'url' => 'The {0} format is invalid.',
80
+		],
81
+		'auth' => [
82
+			'not_registered' => '{0} is not registered with us!',
83
+			'password' => 'Password is not geniune for {0}',
84
+		]
85
+	],
86 86
 
87
-    'messenger' => [
88
-        'new' => '{0, plural, zero {No new message}, one {One new message}, other {You have # new messages}}'
89
-    ]
87
+	'messenger' => [
88
+		'new' => '{0, plural, zero {No new message}, one {One new message}, other {You have # new messages}}'
89
+	]
90 90
 ];
Please login to merge, or discard this patch.
app.php 2 patches
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -2,171 +2,171 @@
 block discarded – undo
2 2
 
3 3
 class app extends Prefab
4 4
 {
5
-    public $db;
6
-    public $app;
7
-    public $session;
8
-    public $authenticatedUser;
9
-
10
-    public function __construct()
11
-    {
12
-        $this->app = $this->app ?: Base::instance();
13
-    }
14
-
15
-    public static function singleton()
16
-    {
17
-        if (Registry::exists('APP')) {
18
-            $app = Registry::get('APP');
19
-        } else {
20
-            $app = new self;
21
-            Registry::set('APP', $app);
22
-        }
23
-        return $app;
24
-    }
25
-
26
-    public function db()
27
-    {
28
-        return $this->db ?: $this->app->DB;
29
-    }
30
-
31
-    public function session()
32
-    {
33
-        return $this->session ?: $this->app->SESSION;
34
-    }
35
-
36
-    public function user()
37
-    {
38
-        return $this->authenticatedUser = $this->app->get('SESSION.USER') ?: false;
39
-    }
40
-
41
-    public function initialized($def = null)
42
-    {
43
-        return null !== $def ? $this->app->set('INITIALIZED', $def) : $this->app->get('INITIALIZED');
44
-    }
45
-
46
-    public function config($key = null)
47
-    {
48
-        return $this->app->get($key ?: 'CONFIG');
49
-    }
50
-
51
-    public function status()
52
-    {
53
-        return $this->app->IS_LIVE;
54
-    }
55
-
56
-    public function run()
57
-    {
58
-        $this->loadConfig();
59
-        $this->loadRoutes();
60
-        $this->checkForMaintenance();
61
-        $this->configureDebug();
62
-        $this->configureDB();
63
-        $this->configureSession();
64
-        $this->configureAssets();
65
-        $this->registerErrorHandler();
66
-        $this->initialized(true);
67
-        $this->app->run();
68
-    }
69
-
70
-    public function loadRoutes($file = null)
71
-    {
72
-        $this->_load('routes', $file);
73
-    }
74
-
75
-    public function loadConfig($file = null)
76
-    {
77
-        $this->_load('config', $file);
78
-    }
79
-
80
-    private function _load($path, $file = null)
81
-    {
82
-        if ($file) {
83
-            $this->app->config(base_path("{path}/{$file}"));
84
-        } else {
85
-            foreach (glob(base_path("{$path}/*.ini")) as $file) {
86
-                $this->app->config($file);
87
-            }
88
-        }
89
-    }
90
-
91
-    public function checkForMaintenance()
92
-    {
93
-        if (!$this->status()) {
94
-            template('maintenance');
95
-            exit();
96
-        }
97
-    }
98
-
99
-    public function configureDebug()
100
-    {
101
-        if (!$this->app->DEV) {
102
-            $this->app->set('DEBUG', 0);
103
-        }
104
-    }
105
-
106
-    public function configureDB()
107
-    {
108
-        $type = strtolower($this->app->DB_TYPE);
109
-
110
-        if ($type == 'jig') {
111
-            $this->db = new DB\Jig($this->app->DB_PATH, DB\Jig::FORMAT_JSON);
112
-        } elseif ($type == 'sql') {
113
-            $this->db = new DB\SQL($this->app->DB, $this->app->DB_USER, $this->app->DB_PSWD);
114
-        } elseif ($type == 'mongo') {
115
-            $this->db = new DB\Mongo($this->app->DB, $this->app->DB_USER);
116
-        }
117
-        $this->app->set('DB', $this->db);
118
-    }
119
-
120
-    public function configureSession()
121
-    {
122
-        $type = strtolower($this->app->SESSION);
123
-
124
-        if ($type) {
125
-            if ($this->app->CSRF && ('jig' == $type || 'sql' == $type || 'mongo' == $type)) {
126
-                $this->configureCSRF($type);
127
-            } elseif ($this->app->CSRF) {
128
-                $this->session = new Session(null, 'CSRF');
129
-            } else {
130
-                if ($type == 'jig' || $type == 'mongo' || $type == 'sql') {
131
-                    $session = str_ireplace('/', '', 'DB\/'.$this->_getDBType($type).'\Session');
132
-                    $this->session = new $session($this->app->DB);
133
-                } else {
134
-                    $this->session = new Session();
135
-                }
136
-            }
137
-            $this->app->set('SESSION', $this->session);
138
-        }
139
-    }
140
-
141
-    public function configureCSRF($type)
142
-    {
143
-        $session = str_ireplace('/', '', 'DB\/'.$this->_getDBType($type).'\Session');
144
-        $this->session = new $session($this->app->DB, 'sessions', null, 'CSRF');
145
-    }
146
-
147
-    private function _getDBType($type)
148
-    {
149
-        if ($type == 'jig' || $type == 'mongo') {
150
-            return ucfirst($type);
151
-        } elseif ($type == 'sql') {
152
-            return strtoupper($type);
153
-        }
154
-    }
155
-
156
-    public function configureAssets()
157
-    {
158
-        $assets = Assets::instance();
159
-        $this->app->set('ASSETS.onFileNotFound', function ($file) {
160
-            echo 'file not found: '.$file;
161
-        });
162
-    }
163
-
164
-    public function registerErrorHandler()
165
-    {
166
-        if ($this->app->DEV) {
167
-            Falsum\Run::handler($this->app->DEBUG != 3);
168
-        } else {
169
-            $this->app->set('ONERROR', 'App\Core\Controllers\ErrorController->init');
170
-        }
171
-    }
5
+	public $db;
6
+	public $app;
7
+	public $session;
8
+	public $authenticatedUser;
9
+
10
+	public function __construct()
11
+	{
12
+		$this->app = $this->app ?: Base::instance();
13
+	}
14
+
15
+	public static function singleton()
16
+	{
17
+		if (Registry::exists('APP')) {
18
+			$app = Registry::get('APP');
19
+		} else {
20
+			$app = new self;
21
+			Registry::set('APP', $app);
22
+		}
23
+		return $app;
24
+	}
25
+
26
+	public function db()
27
+	{
28
+		return $this->db ?: $this->app->DB;
29
+	}
30
+
31
+	public function session()
32
+	{
33
+		return $this->session ?: $this->app->SESSION;
34
+	}
35
+
36
+	public function user()
37
+	{
38
+		return $this->authenticatedUser = $this->app->get('SESSION.USER') ?: false;
39
+	}
40
+
41
+	public function initialized($def = null)
42
+	{
43
+		return null !== $def ? $this->app->set('INITIALIZED', $def) : $this->app->get('INITIALIZED');
44
+	}
45
+
46
+	public function config($key = null)
47
+	{
48
+		return $this->app->get($key ?: 'CONFIG');
49
+	}
50
+
51
+	public function status()
52
+	{
53
+		return $this->app->IS_LIVE;
54
+	}
55
+
56
+	public function run()
57
+	{
58
+		$this->loadConfig();
59
+		$this->loadRoutes();
60
+		$this->checkForMaintenance();
61
+		$this->configureDebug();
62
+		$this->configureDB();
63
+		$this->configureSession();
64
+		$this->configureAssets();
65
+		$this->registerErrorHandler();
66
+		$this->initialized(true);
67
+		$this->app->run();
68
+	}
69
+
70
+	public function loadRoutes($file = null)
71
+	{
72
+		$this->_load('routes', $file);
73
+	}
74
+
75
+	public function loadConfig($file = null)
76
+	{
77
+		$this->_load('config', $file);
78
+	}
79
+
80
+	private function _load($path, $file = null)
81
+	{
82
+		if ($file) {
83
+			$this->app->config(base_path("{path}/{$file}"));
84
+		} else {
85
+			foreach (glob(base_path("{$path}/*.ini")) as $file) {
86
+				$this->app->config($file);
87
+			}
88
+		}
89
+	}
90
+
91
+	public function checkForMaintenance()
92
+	{
93
+		if (!$this->status()) {
94
+			template('maintenance');
95
+			exit();
96
+		}
97
+	}
98
+
99
+	public function configureDebug()
100
+	{
101
+		if (!$this->app->DEV) {
102
+			$this->app->set('DEBUG', 0);
103
+		}
104
+	}
105
+
106
+	public function configureDB()
107
+	{
108
+		$type = strtolower($this->app->DB_TYPE);
109
+
110
+		if ($type == 'jig') {
111
+			$this->db = new DB\Jig($this->app->DB_PATH, DB\Jig::FORMAT_JSON);
112
+		} elseif ($type == 'sql') {
113
+			$this->db = new DB\SQL($this->app->DB, $this->app->DB_USER, $this->app->DB_PSWD);
114
+		} elseif ($type == 'mongo') {
115
+			$this->db = new DB\Mongo($this->app->DB, $this->app->DB_USER);
116
+		}
117
+		$this->app->set('DB', $this->db);
118
+	}
119
+
120
+	public function configureSession()
121
+	{
122
+		$type = strtolower($this->app->SESSION);
123
+
124
+		if ($type) {
125
+			if ($this->app->CSRF && ('jig' == $type || 'sql' == $type || 'mongo' == $type)) {
126
+				$this->configureCSRF($type);
127
+			} elseif ($this->app->CSRF) {
128
+				$this->session = new Session(null, 'CSRF');
129
+			} else {
130
+				if ($type == 'jig' || $type == 'mongo' || $type == 'sql') {
131
+					$session = str_ireplace('/', '', 'DB\/'.$this->_getDBType($type).'\Session');
132
+					$this->session = new $session($this->app->DB);
133
+				} else {
134
+					$this->session = new Session();
135
+				}
136
+			}
137
+			$this->app->set('SESSION', $this->session);
138
+		}
139
+	}
140
+
141
+	public function configureCSRF($type)
142
+	{
143
+		$session = str_ireplace('/', '', 'DB\/'.$this->_getDBType($type).'\Session');
144
+		$this->session = new $session($this->app->DB, 'sessions', null, 'CSRF');
145
+	}
146
+
147
+	private function _getDBType($type)
148
+	{
149
+		if ($type == 'jig' || $type == 'mongo') {
150
+			return ucfirst($type);
151
+		} elseif ($type == 'sql') {
152
+			return strtoupper($type);
153
+		}
154
+	}
155
+
156
+	public function configureAssets()
157
+	{
158
+		$assets = Assets::instance();
159
+		$this->app->set('ASSETS.onFileNotFound', function ($file) {
160
+			echo 'file not found: '.$file;
161
+		});
162
+	}
163
+
164
+	public function registerErrorHandler()
165
+	{
166
+		if ($this->app->DEV) {
167
+			Falsum\Run::handler($this->app->DEBUG != 3);
168
+		} else {
169
+			$this->app->set('ONERROR', 'App\Core\Controllers\ErrorController->init');
170
+		}
171
+	}
172 172
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     {
17 17
         if (Registry::exists('APP')) {
18 18
             $app = Registry::get('APP');
19
-        } else {
19
+        }else {
20 20
             $app = new self;
21 21
             Registry::set('APP', $app);
22 22
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     {
82 82
         if ($file) {
83 83
             $this->app->config(base_path("{path}/{$file}"));
84
-        } else {
84
+        }else {
85 85
             foreach (glob(base_path("{$path}/*.ini")) as $file) {
86 86
                 $this->app->config($file);
87 87
             }
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
                 $this->configureCSRF($type);
127 127
             } elseif ($this->app->CSRF) {
128 128
                 $this->session = new Session(null, 'CSRF');
129
-            } else {
129
+            }else {
130 130
                 if ($type == 'jig' || $type == 'mongo' || $type == 'sql') {
131 131
                     $session = str_ireplace('/', '', 'DB\/'.$this->_getDBType($type).'\Session');
132 132
                     $this->session = new $session($this->app->DB);
133
-                } else {
133
+                }else {
134 134
                     $this->session = new Session();
135 135
                 }
136 136
             }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     public function configureAssets()
157 157
     {
158 158
         $assets = Assets::instance();
159
-        $this->app->set('ASSETS.onFileNotFound', function ($file) {
159
+        $this->app->set('ASSETS.onFileNotFound', function($file) {
160 160
             echo 'file not found: '.$file;
161 161
         });
162 162
     }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     {
166 166
         if ($this->app->DEV) {
167 167
             Falsum\Run::handler($this->app->DEBUG != 3);
168
-        } else {
168
+        }else {
169 169
             $this->app->set('ONERROR', 'App\Core\Controllers\ErrorController->init');
170 170
         }
171 171
     }
Please login to merge, or discard this patch.
bootstrap/helpers.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -2,110 +2,110 @@
 block discarded – undo
2 2
 
3 3
 function f3($get = null)
4 4
 {
5
-    $f3 = Base::instance();
6
-    return $get ? $f3->get($get) : $f3;
5
+	$f3 = Base::instance();
6
+	return $get ? $f3->get($get) : $f3;
7 7
 }
8 8
 
9 9
 function base_path($inner = '')
10 10
 {
11
-    return realpath(__DIR__.'/../').'/'.$inner;
11
+	return realpath(__DIR__.'/../').'/'.$inner;
12 12
 }
13 13
 function storage_path($inner = '')
14 14
 {
15
-    return base_path('storage/').'/'.$inner;
15
+	return base_path('storage/').'/'.$inner;
16 16
 }
17 17
 function db_path($db = '')
18 18
 {
19
-    return storage_path('db/').$db;
19
+	return storage_path('db/').$db;
20 20
 }
21 21
 function lang_path($lang = '')
22 22
 {
23
-    return base_path('resources/lang/').'/'.$lang;
23
+	return base_path('resources/lang/').'/'.$lang;
24 24
 }
25 25
 function views_path()
26 26
 {
27
-    return base_path('resources/views/');
27
+	return base_path('resources/views/');
28 28
 }
29 29
 function config_path($config = '')
30 30
 {
31
-    return base_path('config/').'/'.$config;
31
+	return base_path('config/').'/'.$config;
32 32
 }
33 33
 
34 34
 function abort()
35 35
 {
36
-    f3()->abort();
36
+	f3()->abort();
37 37
 }
38 38
 function status($code = 404)
39 39
 {
40
-    f3()->error($code);
40
+	f3()->error($code);
41 41
 }
42 42
 function reroute($where)
43 43
 {
44
-    f3()->reroute($where);
44
+	f3()->reroute($where);
45 45
 }
46 46
 function is_api($path)
47 47
 {
48
-    if (is_string($path)) {
49
-        return explode('/', $path)[1] === 'api';
50
-    }
51
-    return false;
48
+	if (is_string($path)) {
49
+		return explode('/', $path)[1] === 'api';
50
+	}
51
+	return false;
52 52
 }
53 53
 
54 54
 function template($template, array $params = [], $mime = 'text/html')
55 55
 {
56
-    $f3 = f3();
57
-    if (!empty($params)) {
58
-        $f3->mset($params);
59
-    }
60
-    if (is_array($template)) {
61
-        $layout = $template[0];
62
-        $view = $template[1];
63
-    } else {
64
-        $layout = 'layouts/app.htm';
65
-        $view = $template;
66
-    }
67
-    $f3->set('user', App::instance()->user());
68
-    $f3->set('content', extension($view, 'htm'));
69
-    echo Template::instance()->render($layout, $mime);
56
+	$f3 = f3();
57
+	if (!empty($params)) {
58
+		$f3->mset($params);
59
+	}
60
+	if (is_array($template)) {
61
+		$layout = $template[0];
62
+		$view = $template[1];
63
+	} else {
64
+		$layout = 'layouts/app.htm';
65
+		$view = $template;
66
+	}
67
+	$f3->set('user', App::instance()->user());
68
+	$f3->set('content', extension($view, 'htm'));
69
+	echo Template::instance()->render($layout, $mime);
70 70
 }
71 71
 
72 72
 function str_contains($haystack, $needles)
73 73
 {
74
-    foreach ((array) $needles as $needle) {
75
-        if ($needle != '' && mb_strpos($haystack, $needle) !== false) {
76
-            return true;
77
-        }
78
-    }
79
-    return false;
74
+	foreach ((array) $needles as $needle) {
75
+		if ($needle != '' && mb_strpos($haystack, $needle) !== false) {
76
+			return true;
77
+		}
78
+	}
79
+	return false;
80 80
 }
81 81
 function extension($file, $default = 'json')
82 82
 {
83
-    return $file.'.'.(pathinfo($file, PATHINFO_EXTENSION) ?: $default);
83
+	return $file.'.'.(pathinfo($file, PATHINFO_EXTENSION) ?: $default);
84 84
 }
85 85
 function flash($message, $type = 'success')
86 86
 {
87
-    Flash::instance()->addMessage($message, $type);
87
+	Flash::instance()->addMessage($message, $type);
88 88
 }
89 89
 function trans($key, $params = null)
90 90
 {
91
-    return f3()->format(f3()->get($key), ($params ?: ''));
91
+	return f3()->format(f3()->get($key), ($params ?: ''));
92 92
 }
93 93
 function error($error)
94 94
 {
95
-    if (null === $error) {
96
-        return;
97
-    }
98
-    if (is_array($error)) {
99
-        foreach ($error as $err) {
100
-            if (is_array($err)) {
101
-                foreach ($err as $e) {
102
-                    flash($e, 'danger');
103
-                }
104
-            } else {
105
-                flash($err, 'danger');
106
-            }
107
-        }
108
-    } else {
109
-        flash($error, 'danger');
110
-    }
95
+	if (null === $error) {
96
+		return;
97
+	}
98
+	if (is_array($error)) {
99
+		foreach ($error as $err) {
100
+			if (is_array($err)) {
101
+				foreach ($err as $e) {
102
+					flash($e, 'danger');
103
+				}
104
+			} else {
105
+				flash($err, 'danger');
106
+			}
107
+		}
108
+	} else {
109
+		flash($error, 'danger');
110
+	}
111 111
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     if (is_array($template)) {
61 61
         $layout = $template[0];
62 62
         $view = $template[1];
63
-    } else {
63
+    }else {
64 64
         $layout = 'layouts/app.htm';
65 65
         $view = $template;
66 66
     }
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
                 foreach ($err as $e) {
102 102
                     flash($e, 'danger');
103 103
                 }
104
-            } else {
104
+            }else {
105 105
                 flash($err, 'danger');
106 106
             }
107 107
         }
108
-    } else {
108
+    }else {
109 109
         flash($error, 'danger');
110 110
     }
111 111
 }
Please login to merge, or discard this patch.
helpers/Str.php 1 patch
Indentation   +247 added lines, -247 removed lines patch added patch discarded remove patch
@@ -2,262 +2,262 @@
 block discarded – undo
2 2
 
3 3
 class Str extends Prefab
4 4
 {
5
-    protected static $snakeCache = [];
6
-    protected static $camelCache = [];
7
-    protected static $studlyCache = [];
5
+	protected static $snakeCache = [];
6
+	protected static $camelCache = [];
7
+	protected static $studlyCache = [];
8 8
     
9
-    public static function after($subject, $search)
10
-    {
11
-        return $search === '' ? $subject : array_reverse(explode($search, $subject, 2))[0];
12
-    }
13
-
14
-    public static function before($subject, $search)
15
-    {
16
-        return $search === '' ? $subject : explode($search, $subject)[0];
17
-    }
18
-
19
-    public static function camel($value)
20
-    {
21
-        if (isset(static::$camelCache[$value])) {
22
-            return static::$camelCache[$value];
23
-        }
24
-
25
-        return static::$camelCache[$value] = lcfirst(static::studly($value));
26
-    }
27
-
28
-    public static function contains($haystack, $needles)
29
-    {
30
-        foreach ((array) $needles as $needle) {
31
-            if ($needle !== '' && mb_strpos($haystack, $needle) !== false) {
32
-                return true;
33
-            }
34
-        }
35
-
36
-        return false;
37
-    }
38
-
39
-    public static function endsWith($haystack, $needles)
40
-    {
41
-        foreach ((array) $needles as $needle) {
42
-            if (substr($haystack, -strlen($needle)) === (string) $needle) {
43
-                return true;
44
-            }
45
-        }
46
-
47
-        return false;
48
-    }
49
-
50
-    public static function finish($value, $cap)
51
-    {
52
-        $quoted = preg_quote($cap, '/');
53
-
54
-        return preg_replace('/(?:'.$quoted.')+$/u', '', $value).$cap;
55
-    }
56
-
57
-    public static function is($pattern, $value)
58
-    {
59
-        $patterns = is_array($pattern) ? $pattern : (array) $pattern;
60
-
61
-        if (empty($patterns)) {
62
-            return false;
63
-        }
64
-
65
-        foreach ($patterns as $pattern) {
66
-            if ($pattern == $value) {
67
-                return true;
68
-            }
69
-
70
-            $pattern = preg_quote($pattern, '#');
71
-            $pattern = str_replace('\*', '.*', $pattern);
72
-
73
-            if (preg_match('#^'.$pattern.'\z#u', $value) === 1) {
74
-                return true;
75
-            }
76
-        }
77
-
78
-        return false;
79
-    }
80
-
81
-    public static function kebab($value)
82
-    {
83
-        return static::snake($value, '-');
84
-    }
85
-
86
-    public static function length($value, $encoding = null)
87
-    {
88
-        if ($encoding) {
89
-            return mb_strlen($value, $encoding);
90
-        }
91
-
92
-        return mb_strlen($value);
93
-    }
94
-
95
-    public static function limit($value, $limit = 100, $end = '...')
96
-    {
97
-        if (mb_strwidth($value, 'UTF-8') <= $limit) {
98
-            return $value;
99
-        }
100
-
101
-        return rtrim(mb_strimwidth($value, 0, $limit, '', 'UTF-8')).$end;
102
-    }
103
-
104
-    public static function lower($value)
105
-    {
106
-        return mb_strtolower($value, 'UTF-8');
107
-    }
108
-
109
-    public static function words($value, $words = 100, $end = '...')
110
-    {
111
-        preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches);
112
-
113
-        if (!isset($matches[0]) || static::length($value) === static::length($matches[0])) {
114
-            return $value;
115
-        }
116
-
117
-        return rtrim($matches[0]).$end;
118
-    }
119
-
120
-    public static function parseCallback($callback, $default = null)
121
-    {
122
-        return static::contains($callback, '@') ? explode('@', $callback, 2) : [$callback, $default];
123
-    }
124
-
125
-    public static function plural($value, $count = 2)
126
-    {
127
-        return Pluralizer::plural($value, $count);
128
-    }
129
-
130
-    public static function random($length = 16)
131
-    {
132
-        $string = '';
133
-
134
-        while (($len = strlen($string)) < $length) {
135
-            $size = $length - $len;
136
-            $bytes = random_bytes($size);
137
-            $string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
138
-        }
139
-
140
-        return $string;
141
-    }
142
-
143
-    public static function replaceArray($search, array $replace, $subject)
144
-    {
145
-        foreach ($replace as $value) {
146
-            $subject = static::replaceFirst($search, $value, $subject);
147
-        }
148
-
149
-        return $subject;
150
-    }
151
-
152
-    public static function replaceFirst($search, $replace, $subject)
153
-    {
154
-        if ($search == '') {
155
-            return $subject;
156
-        }
157
-
158
-        $position = strpos($subject, $search);
159
-
160
-        if ($position !== false) {
161
-            return substr_replace($subject, $replace, $position, strlen($search));
162
-        }
163
-
164
-        return $subject;
165
-    }
166
-
167
-    public static function replaceLast($search, $replace, $subject)
168
-    {
169
-        $position = strrpos($subject, $search);
170
-
171
-        if ($position !== false) {
172
-            return substr_replace($subject, $replace, $position, strlen($search));
173
-        }
174
-
175
-        return $subject;
176
-    }
177
-
178
-    public static function start($value, $prefix)
179
-    {
180
-        $quoted = preg_quote($prefix, '/');
181
-        return $prefix.preg_replace('/^(?:'.$quoted.')+/u', '', $value);
182
-    }
183
-
184
-    public static function upper($value)
185
-    {
186
-        return mb_strtoupper($value, 'UTF-8');
187
-    }
188
-
189
-    public static function title($value)
190
-    {
191
-        return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8');
192
-    }
193
-
194
-    public static function singular($value)
195
-    {
196
-        return Pluralizer::singular($value);
197
-    }
198
-
199
-    public static function slug($title, $separator = '-', $language = 'en')
200
-    {
201
-        $title = static::ascii($title, $language);
202
-
203
-        $flip = $separator == '-' ? '_' : '-';
204
-
205
-        $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);
206
-        $title = str_replace('@', $separator.'at'.$separator, $title);
207
-        $title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title));
208
-        $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title);
209
-
210
-        return trim($title, $separator);
211
-    }
9
+	public static function after($subject, $search)
10
+	{
11
+		return $search === '' ? $subject : array_reverse(explode($search, $subject, 2))[0];
12
+	}
13
+
14
+	public static function before($subject, $search)
15
+	{
16
+		return $search === '' ? $subject : explode($search, $subject)[0];
17
+	}
18
+
19
+	public static function camel($value)
20
+	{
21
+		if (isset(static::$camelCache[$value])) {
22
+			return static::$camelCache[$value];
23
+		}
24
+
25
+		return static::$camelCache[$value] = lcfirst(static::studly($value));
26
+	}
27
+
28
+	public static function contains($haystack, $needles)
29
+	{
30
+		foreach ((array) $needles as $needle) {
31
+			if ($needle !== '' && mb_strpos($haystack, $needle) !== false) {
32
+				return true;
33
+			}
34
+		}
35
+
36
+		return false;
37
+	}
38
+
39
+	public static function endsWith($haystack, $needles)
40
+	{
41
+		foreach ((array) $needles as $needle) {
42
+			if (substr($haystack, -strlen($needle)) === (string) $needle) {
43
+				return true;
44
+			}
45
+		}
46
+
47
+		return false;
48
+	}
49
+
50
+	public static function finish($value, $cap)
51
+	{
52
+		$quoted = preg_quote($cap, '/');
53
+
54
+		return preg_replace('/(?:'.$quoted.')+$/u', '', $value).$cap;
55
+	}
56
+
57
+	public static function is($pattern, $value)
58
+	{
59
+		$patterns = is_array($pattern) ? $pattern : (array) $pattern;
60
+
61
+		if (empty($patterns)) {
62
+			return false;
63
+		}
64
+
65
+		foreach ($patterns as $pattern) {
66
+			if ($pattern == $value) {
67
+				return true;
68
+			}
69
+
70
+			$pattern = preg_quote($pattern, '#');
71
+			$pattern = str_replace('\*', '.*', $pattern);
72
+
73
+			if (preg_match('#^'.$pattern.'\z#u', $value) === 1) {
74
+				return true;
75
+			}
76
+		}
77
+
78
+		return false;
79
+	}
80
+
81
+	public static function kebab($value)
82
+	{
83
+		return static::snake($value, '-');
84
+	}
85
+
86
+	public static function length($value, $encoding = null)
87
+	{
88
+		if ($encoding) {
89
+			return mb_strlen($value, $encoding);
90
+		}
91
+
92
+		return mb_strlen($value);
93
+	}
94
+
95
+	public static function limit($value, $limit = 100, $end = '...')
96
+	{
97
+		if (mb_strwidth($value, 'UTF-8') <= $limit) {
98
+			return $value;
99
+		}
100
+
101
+		return rtrim(mb_strimwidth($value, 0, $limit, '', 'UTF-8')).$end;
102
+	}
103
+
104
+	public static function lower($value)
105
+	{
106
+		return mb_strtolower($value, 'UTF-8');
107
+	}
108
+
109
+	public static function words($value, $words = 100, $end = '...')
110
+	{
111
+		preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches);
112
+
113
+		if (!isset($matches[0]) || static::length($value) === static::length($matches[0])) {
114
+			return $value;
115
+		}
116
+
117
+		return rtrim($matches[0]).$end;
118
+	}
119
+
120
+	public static function parseCallback($callback, $default = null)
121
+	{
122
+		return static::contains($callback, '@') ? explode('@', $callback, 2) : [$callback, $default];
123
+	}
124
+
125
+	public static function plural($value, $count = 2)
126
+	{
127
+		return Pluralizer::plural($value, $count);
128
+	}
129
+
130
+	public static function random($length = 16)
131
+	{
132
+		$string = '';
133
+
134
+		while (($len = strlen($string)) < $length) {
135
+			$size = $length - $len;
136
+			$bytes = random_bytes($size);
137
+			$string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
138
+		}
139
+
140
+		return $string;
141
+	}
142
+
143
+	public static function replaceArray($search, array $replace, $subject)
144
+	{
145
+		foreach ($replace as $value) {
146
+			$subject = static::replaceFirst($search, $value, $subject);
147
+		}
148
+
149
+		return $subject;
150
+	}
151
+
152
+	public static function replaceFirst($search, $replace, $subject)
153
+	{
154
+		if ($search == '') {
155
+			return $subject;
156
+		}
157
+
158
+		$position = strpos($subject, $search);
159
+
160
+		if ($position !== false) {
161
+			return substr_replace($subject, $replace, $position, strlen($search));
162
+		}
163
+
164
+		return $subject;
165
+	}
166
+
167
+	public static function replaceLast($search, $replace, $subject)
168
+	{
169
+		$position = strrpos($subject, $search);
170
+
171
+		if ($position !== false) {
172
+			return substr_replace($subject, $replace, $position, strlen($search));
173
+		}
174
+
175
+		return $subject;
176
+	}
177
+
178
+	public static function start($value, $prefix)
179
+	{
180
+		$quoted = preg_quote($prefix, '/');
181
+		return $prefix.preg_replace('/^(?:'.$quoted.')+/u', '', $value);
182
+	}
183
+
184
+	public static function upper($value)
185
+	{
186
+		return mb_strtoupper($value, 'UTF-8');
187
+	}
188
+
189
+	public static function title($value)
190
+	{
191
+		return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8');
192
+	}
193
+
194
+	public static function singular($value)
195
+	{
196
+		return Pluralizer::singular($value);
197
+	}
198
+
199
+	public static function slug($title, $separator = '-', $language = 'en')
200
+	{
201
+		$title = static::ascii($title, $language);
202
+
203
+		$flip = $separator == '-' ? '_' : '-';
204
+
205
+		$title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);
206
+		$title = str_replace('@', $separator.'at'.$separator, $title);
207
+		$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title));
208
+		$title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title);
209
+
210
+		return trim($title, $separator);
211
+	}
212 212
 
213
-    public static function snake($value, $delimiter = '_')
214
-    {
215
-        $key = $value;
213
+	public static function snake($value, $delimiter = '_')
214
+	{
215
+		$key = $value;
216 216
 
217
-        if (isset(static::$snakeCache[$key][$delimiter])) {
218
-            return static::$snakeCache[$key][$delimiter];
219
-        }
220
-
221
-        if (!ctype_lower($value)) {
222
-            $value = preg_replace('/\s+/u', '', ucwords($value));
223
-
224
-            $value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value));
225
-        }
226
-
227
-        return static::$snakeCache[$key][$delimiter] = $value;
228
-    }
217
+		if (isset(static::$snakeCache[$key][$delimiter])) {
218
+			return static::$snakeCache[$key][$delimiter];
219
+		}
220
+
221
+		if (!ctype_lower($value)) {
222
+			$value = preg_replace('/\s+/u', '', ucwords($value));
223
+
224
+			$value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value));
225
+		}
226
+
227
+		return static::$snakeCache[$key][$delimiter] = $value;
228
+	}
229 229
 
230
-    public static function startsWith($haystack, $needles)
231
-    {
232
-        foreach ((array) $needles as $needle) {
233
-            if ($needle !== '' && substr($haystack, 0, strlen($needle)) === (string) $needle) {
234
-                return true;
235
-            }
236
-        }
230
+	public static function startsWith($haystack, $needles)
231
+	{
232
+		foreach ((array) $needles as $needle) {
233
+			if ($needle !== '' && substr($haystack, 0, strlen($needle)) === (string) $needle) {
234
+				return true;
235
+			}
236
+		}
237 237
 
238
-        return false;
239
-    }
238
+		return false;
239
+	}
240 240
 
241
-    public static function studly($value)
242
-    {
243
-        $key = $value;
241
+	public static function studly($value)
242
+	{
243
+		$key = $value;
244 244
 
245
-        if (isset(static::$studlyCache[$key])) {
246
-            return static::$studlyCache[$key];
247
-        }
245
+		if (isset(static::$studlyCache[$key])) {
246
+			return static::$studlyCache[$key];
247
+		}
248 248
 
249
-        $value = ucwords(str_replace(['-', '_'], ' ', $value));
249
+		$value = ucwords(str_replace(['-', '_'], ' ', $value));
250 250
 
251
-        return static::$studlyCache[$key] = str_replace(' ', '', $value);
252
-    }
251
+		return static::$studlyCache[$key] = str_replace(' ', '', $value);
252
+	}
253 253
 
254
-    public static function substr($string, $start, $length = null)
255
-    {
256
-        return mb_substr($string, $start, $length, 'UTF-8');
257
-    }
254
+	public static function substr($string, $start, $length = null)
255
+	{
256
+		return mb_substr($string, $start, $length, 'UTF-8');
257
+	}
258 258
 
259
-    public static function ucfirst($string)
260
-    {
261
-        return static::upper(static::substr($string, 0, 1)).static::substr($string, 1);
262
-    }
259
+	public static function ucfirst($string)
260
+	{
261
+		return static::upper(static::substr($string, 0, 1)).static::substr($string, 1);
262
+	}
263 263
 }
Please login to merge, or discard this patch.