@@ -41,14 +41,18 @@ |
||
41 | 41 | |
42 | 42 | foreach (['full_name', 'city'] as $name) { |
43 | 43 | |
44 | - if ('' === ($text = Auth::get($name))) $contents->getBlock($name)->disable(); |
|
45 | - |
|
46 | - else $contents->getBlock($name)->text = $text; |
|
44 | + if ('' === ($text = Auth::get($name))) { |
|
45 | + $contents->getBlock($name)->disable(); |
|
46 | + } else { |
|
47 | + $contents->getBlock($name)->text = $text; |
|
48 | + } |
|
47 | 49 | } |
48 | 50 | |
49 | 51 | # Set country |
50 | 52 | |
51 | - if ('' === ($country = Auth::get('country'))) $contents->getBlock('country')->disable(); else { |
|
53 | + if ('' === ($country = Auth::get('country'))) { |
|
54 | + $contents->getBlock('country')->disable(); |
|
55 | + } else { |
|
52 | 56 | |
53 | 57 | $contents->getBlock('country')->code = $country; |
54 | 58 |
@@ -33,13 +33,19 @@ discard block |
||
33 | 33 | |
34 | 34 | # Validate values |
35 | 35 | |
36 | - if (false === ($email = Validate::userEmail($email))) return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
36 | + if (false === ($email = Validate::userEmail($email))) { |
|
37 | + return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
38 | + } |
|
37 | 39 | |
38 | 40 | # Check email exists |
39 | 41 | |
40 | - if (false === ($check_email = Auth::getUser()->check($email, 'email'))) return 'USER_ERROR_EDIT_PERSONAL'; |
|
42 | + if (false === ($check_email = Auth::getUser()->check($email, 'email'))) { |
|
43 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
44 | + } |
|
41 | 45 | |
42 | - if ($check_email === 1) return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
46 | + if ($check_email === 1) { |
|
47 | + return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
48 | + } |
|
43 | 49 | |
44 | 50 | # Update user |
45 | 51 | |
@@ -53,7 +59,9 @@ discard block |
||
53 | 59 | $data['country'] = $country; |
54 | 60 | $data['timezone'] = $timezone; |
55 | 61 | |
56 | - if (!Auth::getUser()->edit($data)) return 'USER_ERROR_EDIT_PERSONAL'; |
|
62 | + if (!Auth::getUser()->edit($data)) { |
|
63 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
64 | + } |
|
57 | 65 | |
58 | 66 | # ------------------------ |
59 | 67 |
@@ -33,23 +33,28 @@ discard block |
||
33 | 33 | |
34 | 34 | # Validate values |
35 | 35 | |
36 | - if (false === ($password = Validate::userPassword($password))) |
|
37 | - |
|
36 | + if (false === ($password = Validate::userPassword($password))) { |
|
37 | + |
|
38 | 38 | return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
39 | + } |
|
39 | 40 | |
40 | - if (false === ($password_new = Validate::userPassword($password_new))) |
|
41 | - |
|
41 | + if (false === ($password_new = Validate::userPassword($password_new))) { |
|
42 | + |
|
42 | 43 | return ['password_new', 'USER_ERROR_PASSWORD_NEW_INVALID']; |
44 | + } |
|
43 | 45 | |
44 | - if (0 !== strcmp($password_new, $password_retype)) |
|
45 | - |
|
46 | + if (0 !== strcmp($password_new, $password_retype)) { |
|
47 | + |
|
46 | 48 | return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
49 | + } |
|
47 | 50 | |
48 | 51 | # Check password |
49 | 52 | |
50 | 53 | $password = Str::encode(Auth::get('auth_key'), $password); |
51 | 54 | |
52 | - if (0 !== strcmp(Auth::get('password'), $password)) return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
55 | + if (0 !== strcmp(Auth::get('password'), $password)) { |
|
56 | + return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
57 | + } |
|
53 | 58 | |
54 | 59 | # Encode password |
55 | 60 | |
@@ -62,7 +67,9 @@ discard block |
||
62 | 67 | $data['auth_key'] = $auth_key; |
63 | 68 | $data['password'] = $password; |
64 | 69 | |
65 | - if (!Auth::getUser()->edit($data)) return 'USER_ERROR_EDIT_PASSWORD'; |
|
70 | + if (!Auth::getUser()->edit($data)) { |
|
71 | + return 'USER_ERROR_EDIT_PASSWORD'; |
|
72 | + } |
|
66 | 73 | |
67 | 74 | # ------------------------ |
68 | 75 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | # Check auth |
35 | 35 | |
36 | - if (($this instanceof Area\Auth) && Auth::isLogged()) Request::redirect(INSTALL_PATH . '/admin'); |
|
36 | + if (($this instanceof Area\Auth) && Auth::isLogged()) Request::redirect(INSTALL_PATH.'/admin'); |
|
37 | 37 | |
38 | 38 | # Handle request |
39 | 39 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | if (!Auth::isLogged() || ((false !== Request::get('logout')) && Auth::logout())) { |
56 | 56 | |
57 | - Request::redirect(INSTALL_PATH . '/admin/login'); |
|
57 | + Request::redirect(INSTALL_PATH.'/admin/login'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | # Handle request |
@@ -33,11 +33,15 @@ discard block |
||
33 | 33 | |
34 | 34 | # Check auth |
35 | 35 | |
36 | - if (($this instanceof Area\Auth) && Auth::isLogged()) Request::redirect(INSTALL_PATH . '/admin'); |
|
36 | + if (($this instanceof Area\Auth) && Auth::isLogged()) { |
|
37 | + Request::redirect(INSTALL_PATH . '/admin'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | # Handle request |
39 | 41 | |
40 | - if (Template::isBlock($result = $this->handle())) return (new View\Form($this->_title))->display($result); |
|
42 | + if (Template::isBlock($result = $this->handle())) { |
|
43 | + return (new View\Form($this->_title))->display($result); |
|
44 | + } |
|
41 | 45 | |
42 | 46 | # ------------------------ |
43 | 47 | |
@@ -63,9 +67,13 @@ discard block |
||
63 | 67 | |
64 | 68 | $result = $this->handle(Request::isAjax() && ($request === 'display')); |
65 | 69 | |
66 | - if (Template::isBlock($result)) return (new View\Panel($this->_title))->$request($result); |
|
70 | + if (Template::isBlock($result)) { |
|
71 | + return (new View\Panel($this->_title))->$request($result); |
|
72 | + } |
|
67 | 73 | |
68 | - if (Ajax::isResponse($result)) return Ajax::output($result); |
|
74 | + if (Ajax::isResponse($result)) { |
|
75 | + return Ajax::output($result); |
|
76 | + } |
|
69 | 77 | |
70 | 78 | # ------------------------ |
71 | 79 | |
@@ -84,14 +92,20 @@ discard block |
||
84 | 92 | |
85 | 93 | $ips = preg_split('/ +/', CONFIG_ADMIN_IP, -1, PREG_SPLIT_NO_EMPTY); |
86 | 94 | |
87 | - if (!in_array(REQUEST_CLIENT_IP, $ips, true)) return Status::displayError404(); |
|
95 | + if (!in_array(REQUEST_CLIENT_IP, $ips, true)) { |
|
96 | + return Status::displayError404(); |
|
97 | + } |
|
88 | 98 | } |
89 | 99 | |
90 | 100 | # Handle request |
91 | 101 | |
92 | - if (($this instanceof Area\Auth) || ($this instanceof Area\Install)) return $this->handleFormArea(); |
|
102 | + if (($this instanceof Area\Auth) || ($this instanceof Area\Install)) { |
|
103 | + return $this->handleFormArea(); |
|
104 | + } |
|
93 | 105 | |
94 | - if ($this instanceof Area\Panel) return $this->handlePanelArea(); |
|
106 | + if ($this instanceof Area\Panel) { |
|
107 | + return $this->handlePanelArea(); |
|
108 | + } |
|
95 | 109 | |
96 | 110 | # ------------------------ |
97 | 111 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | # Check auth |
35 | 35 | |
36 | - if (Auth::isLogged()) Request::redirect(INSTALL_PATH . '/profile'); |
|
36 | + if (Auth::isLogged()) Request::redirect(INSTALL_PATH.'/profile'); |
|
37 | 37 | |
38 | 38 | # ------------------------ |
39 | 39 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | if (!Auth::isLogged() || ((false !== Request::get('logout')) && Auth::logout())) { |
52 | 52 | |
53 | - Request::redirect(INSTALL_PATH . '/profile/login'); |
|
53 | + Request::redirect(INSTALL_PATH.'/profile/login'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | # ------------------------ |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | |
34 | 34 | # Check auth |
35 | 35 | |
36 | - if (Auth::isLogged()) Request::redirect(INSTALL_PATH . '/profile'); |
|
36 | + if (Auth::isLogged()) { |
|
37 | + Request::redirect(INSTALL_PATH . '/profile'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | # ------------------------ |
39 | 41 | |
@@ -68,9 +70,13 @@ discard block |
||
68 | 70 | |
69 | 71 | $result = $this->handle(Request::isAjax()); |
70 | 72 | |
71 | - if (Template::isBlock($result)) return (new View($this->_title, $this->_layout))->display($result); |
|
73 | + if (Template::isBlock($result)) { |
|
74 | + return (new View($this->_title, $this->_layout))->display($result); |
|
75 | + } |
|
72 | 76 | |
73 | - if (Ajax::isResponse($result)) return Ajax::output($result); |
|
77 | + if (Ajax::isResponse($result)) { |
|
78 | + return Ajax::output($result); |
|
79 | + } |
|
74 | 80 | |
75 | 81 | # ------------------------ |
76 | 82 | |
@@ -85,17 +91,27 @@ discard block |
||
85 | 91 | |
86 | 92 | # Check site status |
87 | 93 | |
88 | - if (Settings::get('site_status') === STATUS_MAINTENANCE) return Status::displayMaintenance(); |
|
94 | + if (Settings::get('site_status') === STATUS_MAINTENANCE) { |
|
95 | + return Status::displayMaintenance(); |
|
96 | + } |
|
89 | 97 | |
90 | - if (Settings::get('site_status') === STATUS_UPDATE) return Status::displayUpdate(); |
|
98 | + if (Settings::get('site_status') === STATUS_UPDATE) { |
|
99 | + return Status::displayUpdate(); |
|
100 | + } |
|
91 | 101 | |
92 | 102 | # Handle request |
93 | 103 | |
94 | - if ($this instanceof Area\Auth) return $this->handleAuthArea(); |
|
104 | + if ($this instanceof Area\Auth) { |
|
105 | + return $this->handleAuthArea(); |
|
106 | + } |
|
95 | 107 | |
96 | - if ($this instanceof Area\Authorized) return $this->handleAuthorizedArea(); |
|
108 | + if ($this instanceof Area\Authorized) { |
|
109 | + return $this->handleAuthorizedArea(); |
|
110 | + } |
|
97 | 111 | |
98 | - if ($this instanceof Area\Common) return $this->handleCommonArea(); |
|
112 | + if ($this instanceof Area\Common) { |
|
113 | + return $this->handleCommonArea(); |
|
114 | + } |
|
99 | 115 | |
100 | 116 | # ------------------------ |
101 | 117 |
@@ -9,32 +9,32 @@ |
||
9 | 9 | |
10 | 10 | namespace Exception { |
11 | 11 | |
12 | - class Captcha extends Exception { |
|
12 | + class Captcha extends Exception { |
|
13 | 13 | |
14 | 14 | protected $message = 'Error generating captcha'; |
15 | 15 | } |
16 | 16 | |
17 | - class Sitemap extends Exception { |
|
17 | + class Sitemap extends Exception { |
|
18 | 18 | |
19 | 19 | protected $message = 'Error generating sitemap'; |
20 | 20 | } |
21 | 21 | |
22 | - class Language extends Exception { |
|
22 | + class Language extends Exception { |
|
23 | 23 | |
24 | 24 | protected $message = 'Languages not found'; |
25 | 25 | } |
26 | 26 | |
27 | - class Template extends Exception { |
|
27 | + class Template extends Exception { |
|
28 | 28 | |
29 | 29 | protected $message = 'Templates not found'; |
30 | 30 | } |
31 | 31 | |
32 | - class View extends Exception { |
|
32 | + class View extends Exception { |
|
33 | 33 | |
34 | 34 | protected $message = 'View is not initialized'; |
35 | 35 | } |
36 | 36 | |
37 | - class ViewFile extends Exception { |
|
37 | + class ViewFile extends Exception { |
|
38 | 38 | |
39 | 39 | protected $message = 'View file \'$value$\' not found'; |
40 | 40 | } |
@@ -19,7 +19,9 @@ discard block |
||
19 | 19 | |
20 | 20 | public static function start(string $name, int $lifetime) : bool { |
21 | 21 | |
22 | - if (session_id()) return true; |
|
22 | + if (session_id()) { |
|
23 | + return true; |
|
24 | + } |
|
23 | 25 | |
24 | 26 | ini_set('session.gc_maxlifetime', $lifetime); |
25 | 27 | |
@@ -47,7 +49,9 @@ discard block |
||
47 | 49 | |
48 | 50 | public static function set(string $name, $value) { |
49 | 51 | |
50 | - if (session_id()) $_SESSION[$name] = $value; |
|
52 | + if (session_id()) { |
|
53 | + $_SESSION[$name] = $value; |
|
54 | + } |
|
51 | 55 | } |
52 | 56 | |
53 | 57 | /** |
@@ -76,7 +80,9 @@ discard block |
||
76 | 80 | |
77 | 81 | public static function delete(string $name) { |
78 | 82 | |
79 | - if (isset($_SESSION[$name])) unset($_SESSION[$name]); |
|
83 | + if (isset($_SESSION[$name])) { |
|
84 | + unset($_SESSION[$name]); |
|
85 | + } |
|
80 | 86 | } |
81 | 87 | } |
82 | 88 | } |
@@ -73,25 +73,25 @@ discard block |
||
73 | 73 | |
74 | 74 | $pattern = [ |
75 | 75 | |
76 | - 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', |
|
77 | - 'Д' => 'D', 'Е' => 'E', 'Ж' => 'ZH', 'З' => 'Z', |
|
78 | - 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', |
|
79 | - 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', |
|
80 | - 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', |
|
81 | - 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', |
|
82 | - 'Ш' => 'SH', 'Щ' => 'SCH', 'Ъ' => '', 'Ь' => '', |
|
83 | - 'Ы' => 'Y', 'Э' => 'E', 'Ю' => 'JU', 'Я' => 'JA', |
|
84 | - 'І' => 'I', 'Ї' => 'JI', 'Ё' => 'JO', |
|
85 | - |
|
86 | - 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', |
|
87 | - 'д' => 'd', 'е' => 'e', 'ж' => 'zh', 'з' => 'z', |
|
88 | - 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', |
|
89 | - 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', |
|
90 | - 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', |
|
91 | - 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', |
|
92 | - 'ш' => 'sh', 'щ' => 'sch', 'ъ' => '', 'ь' => '', |
|
93 | - 'ы' => 'y', 'э' => 'e', 'ю' => 'ju', 'я' => 'ja', |
|
94 | - 'і' => 'i', 'ї' => 'ji', 'ё' => 'jo' |
|
76 | + 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', |
|
77 | + 'Д' => 'D', 'Е' => 'E', 'Ж' => 'ZH', 'З' => 'Z', |
|
78 | + 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', |
|
79 | + 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', |
|
80 | + 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', |
|
81 | + 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', |
|
82 | + 'Ш' => 'SH', 'Щ' => 'SCH', 'Ъ' => '', 'Ь' => '', |
|
83 | + 'Ы' => 'Y', 'Э' => 'E', 'Ю' => 'JU', 'Я' => 'JA', |
|
84 | + 'І' => 'I', 'Ї' => 'JI', 'Ё' => 'JO', |
|
85 | + |
|
86 | + 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', |
|
87 | + 'д' => 'd', 'е' => 'e', 'ж' => 'zh', 'з' => 'z', |
|
88 | + 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', |
|
89 | + 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', |
|
90 | + 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', |
|
91 | + 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', |
|
92 | + 'ш' => 'sh', 'щ' => 'sch', 'ъ' => '', 'ь' => '', |
|
93 | + 'ы' => 'y', 'э' => 'e', 'ю' => 'ju', 'я' => 'ja', |
|
94 | + 'і' => 'i', 'ї' => 'ji', 'ё' => 'jo' |
|
95 | 95 | ]; |
96 | 96 | |
97 | 97 | # ------------------------ |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | if (($maxlength < 1) || (self::length($string = trim($string)) <= $maxlength)) return $string; |
178 | 178 | |
179 | - $string = (rtrim(self::substr($string, 0, $maxlength)) . ($ellipsis ? '...' : '')); |
|
179 | + $string = (rtrim(self::substr($string, 0, $maxlength)).($ellipsis ? '...' : '')); |
|
180 | 180 | |
181 | 181 | # ------------------------ |
182 | 182 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | public static function encode(string $salt, string $string) : string { |
206 | 206 | |
207 | - return sha1($salt . substr(sha1($string), 8, 32)); |
|
207 | + return sha1($salt.substr(sha1($string), 8, 32)); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
@@ -22,14 +22,18 @@ discard block |
||
22 | 22 | |
23 | 23 | foreach (($string = explode("\n", $string)) as $key => $line) { |
24 | 24 | |
25 | - if ($multiline && $codestyle) $string[$key] = rtrim(preg_replace('/[\r\0\x0B]+/', '', $line)); |
|
26 | - |
|
27 | - else $string[$key] = trim(preg_replace(['/[ \t]+/', '/[\r\0\x0B]+/'], [' ', ''], $line)); |
|
25 | + if ($multiline && $codestyle) { |
|
26 | + $string[$key] = rtrim(preg_replace('/[\r\0\x0B]+/', '', $line)); |
|
27 | + } else { |
|
28 | + $string[$key] = trim(preg_replace(['/[ \t]+/', '/[\r\0\x0B]+/'], [' ', ''], $line)); |
|
29 | + } |
|
28 | 30 | } |
29 | 31 | |
30 | - if (!$multiline) $string = preg_replace('/ {2,}/', ' ', trim(implode(' ', $string), ' ')); |
|
31 | - |
|
32 | - else $string = preg_replace('/(\r\n){3,}/', "\r\n\r\n", trim(implode("\r\n", $string), "\r\n")); |
|
32 | + if (!$multiline) { |
|
33 | + $string = preg_replace('/ {2,}/', ' ', trim(implode(' ', $string), ' ')); |
|
34 | + } else { |
|
35 | + $string = preg_replace('/(\r\n){3,}/', "\r\n\r\n", trim(implode("\r\n", $string), "\r\n")); |
|
36 | + } |
|
33 | 37 | |
34 | 38 | # ------------------------ |
35 | 39 | |
@@ -174,7 +178,9 @@ discard block |
||
174 | 178 | |
175 | 179 | public static function cut(string $string, int $maxlength, bool $ellipsis = false) : string { |
176 | 180 | |
177 | - if (($maxlength < 1) || (self::length($string = trim($string)) <= $maxlength)) return $string; |
|
181 | + if (($maxlength < 1) || (self::length($string = trim($string)) <= $maxlength)) { |
|
182 | + return $string; |
|
183 | + } |
|
178 | 184 | |
179 | 185 | $string = (rtrim(self::substr($string, 0, $maxlength)) . ($ellipsis ? '...' : '')); |
180 | 186 | |
@@ -189,9 +195,13 @@ discard block |
||
189 | 195 | |
190 | 196 | public static function random(int $length, string $pool = STR_POOL_DEFAULT) : string { |
191 | 197 | |
192 | - if (($length < 1) || (0 === ($pool_length = self::length($pool)))) return ''; |
|
198 | + if (($length < 1) || (0 === ($pool_length = self::length($pool)))) { |
|
199 | + return ''; |
|
200 | + } |
|
193 | 201 | |
194 | - $string = ''; for ($i = 0; $i < $length; $i++) $string .= self::substr($pool, random_int(0, ($pool_length - 1)), 1); |
|
202 | + $string = ''; for ($i = 0; $i < $length; $i++) { |
|
203 | + $string .= self::substr($pool, random_int(0, ($pool_length - 1)), 1); |
|
204 | + } |
|
195 | 205 | |
196 | 206 | # ------------------------ |
197 | 207 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | protected function getValue(string $value) : string { |
32 | 32 | |
33 | - return ('\'' . addslashes($value) . '\''); |
|
33 | + return ('\''.addslashes($value).'\''); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | $parser = function($value) { if (is_scalar($value)) return $this->getValue($value); }; |
43 | 43 | |
44 | - return ('(' . implode(', ', array_filter(array_map($parser, $value))) . ')'); |
|
44 | + return ('('.implode(', ', array_filter(array_map($parser, $value))).')'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -50,21 +50,21 @@ discard block |
||
50 | 50 | |
51 | 51 | protected function getOperatable($value) { |
52 | 52 | |
53 | - if (is_scalar($value)) return ('= ' . $this->getValue($value)); |
|
53 | + if (is_scalar($value)) return ('= '.$this->getValue($value)); |
|
54 | 54 | |
55 | - if (is_array($value)) return ('IN ' . $this->getRange($value)); |
|
55 | + if (is_array($value)) return ('IN '.$this->getRange($value)); |
|
56 | 56 | |
57 | - if ($value instanceof Type\Not) return ('NOT ' . $this->getValue($value->get())); |
|
57 | + if ($value instanceof Type\Not) return ('NOT '.$this->getValue($value->get())); |
|
58 | 58 | |
59 | - if ($value instanceof Type\Like) return ('LIKE ' . $this->getValue($value->get())); |
|
59 | + if ($value instanceof Type\Like) return ('LIKE '.$this->getValue($value->get())); |
|
60 | 60 | |
61 | - if ($value instanceof Type\LessThan) return ('< ' . $value->get()); |
|
61 | + if ($value instanceof Type\LessThan) return ('< '.$value->get()); |
|
62 | 62 | |
63 | - if ($value instanceof Type\GreaterThan) return ('> ' . $value->get()); |
|
63 | + if ($value instanceof Type\GreaterThan) return ('> '.$value->get()); |
|
64 | 64 | |
65 | - if ($value instanceof Type\LessThanOrEqual) return ('<= ' . $value->get()); |
|
65 | + if ($value instanceof Type\LessThanOrEqual) return ('<= '.$value->get()); |
|
66 | 66 | |
67 | - if ($value instanceof Type\GreaterThanOrEqual) return ('>= ' . $value->get()); |
|
67 | + if ($value instanceof Type\GreaterThanOrEqual) return ('>= '.$value->get()); |
|
68 | 68 | |
69 | 69 | # ------------------------ |
70 | 70 |
@@ -39,7 +39,10 @@ discard block |
||
39 | 39 | |
40 | 40 | protected function getRange(array $value) : string { |
41 | 41 | |
42 | - $parser = function($value) { if (is_scalar($value)) return $this->getValue($value); }; |
|
42 | + $parser = function($value) { if (is_scalar($value)) { |
|
43 | + return $this->getValue($value); |
|
44 | + } |
|
45 | + }; |
|
43 | 46 | |
44 | 47 | return ('(' . implode(', ', array_filter(array_map($parser, $value))) . ')'); |
45 | 48 | } |
@@ -50,21 +53,37 @@ discard block |
||
50 | 53 | |
51 | 54 | protected function getOperatable($value) { |
52 | 55 | |
53 | - if (is_scalar($value)) return ('= ' . $this->getValue($value)); |
|
56 | + if (is_scalar($value)) { |
|
57 | + return ('= ' . $this->getValue($value)); |
|
58 | + } |
|
54 | 59 | |
55 | - if (is_array($value)) return ('IN ' . $this->getRange($value)); |
|
60 | + if (is_array($value)) { |
|
61 | + return ('IN ' . $this->getRange($value)); |
|
62 | + } |
|
56 | 63 | |
57 | - if ($value instanceof Type\Not) return ('NOT ' . $this->getValue($value->get())); |
|
64 | + if ($value instanceof Type\Not) { |
|
65 | + return ('NOT ' . $this->getValue($value->get())); |
|
66 | + } |
|
58 | 67 | |
59 | - if ($value instanceof Type\Like) return ('LIKE ' . $this->getValue($value->get())); |
|
68 | + if ($value instanceof Type\Like) { |
|
69 | + return ('LIKE ' . $this->getValue($value->get())); |
|
70 | + } |
|
60 | 71 | |
61 | - if ($value instanceof Type\LessThan) return ('< ' . $value->get()); |
|
72 | + if ($value instanceof Type\LessThan) { |
|
73 | + return ('< ' . $value->get()); |
|
74 | + } |
|
62 | 75 | |
63 | - if ($value instanceof Type\GreaterThan) return ('> ' . $value->get()); |
|
76 | + if ($value instanceof Type\GreaterThan) { |
|
77 | + return ('> ' . $value->get()); |
|
78 | + } |
|
64 | 79 | |
65 | - if ($value instanceof Type\LessThanOrEqual) return ('<= ' . $value->get()); |
|
80 | + if ($value instanceof Type\LessThanOrEqual) { |
|
81 | + return ('<= ' . $value->get()); |
|
82 | + } |
|
66 | 83 | |
67 | - if ($value instanceof Type\GreaterThanOrEqual) return ('>= ' . $value->get()); |
|
84 | + if ($value instanceof Type\GreaterThanOrEqual) { |
|
85 | + return ('>= ' . $value->get()); |
|
86 | + } |
|
68 | 87 | |
69 | 88 | # ------------------------ |
70 | 89 | |
@@ -86,7 +105,9 @@ discard block |
||
86 | 105 | |
87 | 106 | protected function getString($source = null, string $pattern = '', string $separator = '') : string { |
88 | 107 | |
89 | - if (!is_array($source)) return (is_scalar($source) ? strval($source) : ''); |
|
108 | + if (!is_array($source)) { |
|
109 | + return (is_scalar($source) ? strval($source) : ''); |
|
110 | + } |
|
90 | 111 | |
91 | 112 | $regexs = ['key' => '/\^([a-z]+)/', 'value' => '/\$([a-z]+)/']; $matches = ['key' => [], 'value' => []]; |
92 | 113 | |
@@ -98,7 +119,9 @@ discard block |
||
98 | 119 | |
99 | 120 | # Parse pattern |
100 | 121 | |
101 | - foreach ($regexs as $name => $regex) preg_match($regex, $pattern, $matches[$name]); |
|
122 | + foreach ($regexs as $name => $regex) { |
|
123 | + preg_match($regex, $pattern, $matches[$name]); |
|
124 | + } |
|
102 | 125 | |
103 | 126 | # Process replacements |
104 | 127 | |
@@ -106,9 +129,12 @@ discard block |
||
106 | 129 | |
107 | 130 | $output[$count] = $pattern; $item = &$output[$count++]; |
108 | 131 | |
109 | - foreach ($matches as $name => $match) if (isset($match[1]) && isset($parsers[$match[1]])) { |
|
132 | + foreach ($matches as $name => $match) { |
|
133 | + if (isset($match[1]) && isset($parsers[$match[1]])) { |
|
110 | 134 | |
111 | - try { $replace = [$this, $parsers[$match[1]]]($$name); } catch (\TypeError $e) { $replace = ''; } |
|
135 | + try { $replace = [$this, $parsers[$match[1]]]($$name); |
|
136 | + } |
|
137 | + } catch (\TypeError $e) { $replace = ''; } |
|
112 | 138 | |
113 | 139 | $item = str_replace($match[0], $replace, $item); |
114 | 140 | } |