@@ -20,9 +20,11 @@ |
||
| 20 | 20 | |
| 21 | 21 | $names = ''; $values = []; |
| 22 | 22 | |
| 23 | - foreach ($dataset as $key => $row) if (is_array($row)) { |
|
| 23 | + foreach ($dataset as $key => $row) { |
|
| 24 | + if (is_array($row)) { |
|
| 24 | 25 | |
| 25 | 26 | if (0 === $key) $names = $this->getString(array_keys($row), '$name', ', '); |
| 27 | + } |
|
| 26 | 28 | |
| 27 | 29 | $values[] = ('(' . $this->getString(array_values($row), '$value', ', ') . ')'); |
| 28 | 30 | } |
@@ -24,14 +24,14 @@ |
||
| 24 | 24 | |
| 25 | 25 | if (0 === $key) $names = $this->getString(array_keys($row), '$name', ', '); |
| 26 | 26 | |
| 27 | - $values[] = ('(' . $this->getString(array_values($row), '$value', ', ') . ')'); |
|
| 27 | + $values[] = ('('.$this->getString(array_values($row), '$value', ', ').')'); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | # Build query |
| 31 | 31 | |
| 32 | - $this->query = ('INSERT ' . ($ignore ? 'IGNORE ' : '') . |
|
| 32 | + $this->query = ('INSERT '.($ignore ? 'IGNORE ' : ''). |
|
| 33 | 33 | |
| 34 | - 'INTO ' . $table . ' (' . $names . ') VALUES ' . implode(', ', $values)); |
|
| 34 | + 'INTO '.$table.' ('.$names.') VALUES '.implode(', ', $values)); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -40,7 +40,9 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | public function row() { |
| 42 | 42 | |
| 43 | - if (!is_object($this->result)) return null; |
|
| 43 | + if (!is_object($this->result)) { |
|
| 44 | + return null; |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | return mysqli_fetch_assoc($this->result); |
| 46 | 48 | } |
@@ -49,9 +51,13 @@ discard block |
||
| 49 | 51 | |
| 50 | 52 | public function rows() { |
| 51 | 53 | |
| 52 | - if (!is_object($this->result)) return []; |
|
| 54 | + if (!is_object($this->result)) { |
|
| 55 | + return []; |
|
| 56 | + } |
|
| 53 | 57 | |
| 54 | - $rows = []; while (null !== ($row = $this->row())) $rows[] = $row; |
|
| 58 | + $rows = []; while (null !== ($row = $this->row())) { |
|
| 59 | + $rows[] = $row; |
|
| 60 | + } |
|
| 55 | 61 | |
| 56 | 62 | # ------------------------ |
| 57 | 63 | |
@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | protected function getString($source = null, string $pattern = '', string $separator = '') { |
| 33 | 33 | |
| 34 | - if (!is_array($source)) return (is_scalar($source) ? strval($source) : ''); |
|
| 34 | + if (!is_array($source)) { |
|
| 35 | + return (is_scalar($source) ? strval($source) : ''); |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | $regexs = ['key' => '/\^([a-z]+)/', 'value' => '/\$([a-z]+)/']; $matches = ['key' => [], 'value' => []]; |
| 37 | 39 | |
@@ -39,18 +41,25 @@ discard block |
||
| 39 | 41 | |
| 40 | 42 | # Parse pattern |
| 41 | 43 | |
| 42 | - foreach ($regexs as $name => $regex) preg_match($regex, $pattern, $matches[$name]); |
|
| 44 | + foreach ($regexs as $name => $regex) { |
|
| 45 | + preg_match($regex, $pattern, $matches[$name]); |
|
| 46 | + } |
|
| 43 | 47 | |
| 44 | 48 | # Process replacements |
| 45 | 49 | |
| 46 | - foreach ($source as $key => $value) if (is_scalar($value)) { |
|
| 50 | + foreach ($source as $key => $value) { |
|
| 51 | + if (is_scalar($value)) { |
|
| 47 | 52 | |
| 48 | - $output[$count] = $pattern; $item = &$output[$count++]; |
|
| 53 | + $output[$count] = $pattern; |
|
| 54 | + } |
|
| 55 | + $item = &$output[$count++]; |
|
| 49 | 56 | |
| 50 | - foreach ($matches as $name => $match) if (isset($match[1]) && isset($parsers[$match[1]])) { |
|
| 57 | + foreach ($matches as $name => $match) { |
|
| 58 | + if (isset($match[1]) && isset($parsers[$match[1]])) { |
|
| 51 | 59 | |
| 52 | 60 | $item = str_replace($match[0], [$this, $parsers[$match[1]]]($$name), $item); |
| 53 | 61 | } |
| 62 | + } |
|
| 54 | 63 | }; |
| 55 | 64 | |
| 56 | 65 | # ------------------------ |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | |
| 18 | 18 | protected function getValue(string $value) { |
| 19 | 19 | |
| 20 | - return ('\'' . addslashes($value) . '\''); |
|
| 20 | + return ('\''.addslashes($value).'\''); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | # Get field sort |
@@ -117,7 +117,9 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | public static function status(string $code) { |
| 119 | 119 | |
| 120 | - if (self::isStatusCode($code)) header(getenv('SERVER_PROTOCOL') . ' ' . self::$status_codes[$code]); |
|
| 120 | + if (self::isStatusCode($code)) { |
|
| 121 | + header(getenv('SERVER_PROTOCOL') . ' ' . self::$status_codes[$code]); |
|
| 122 | + } |
|
| 121 | 123 | } |
| 122 | 124 | |
| 123 | 125 | # Send content header |
@@ -139,9 +141,13 @@ discard block |
||
| 139 | 141 | |
| 140 | 142 | public static function cache(string $limiter, int $expires) { |
| 141 | 143 | |
| 142 | - if (self::$cache_send) return; |
|
| 144 | + if (self::$cache_send) { |
|
| 145 | + return; |
|
| 146 | + } |
|
| 143 | 147 | |
| 144 | - if (!in_array($limiter, [CACHE_LIMITER_PRIVATE, CACHE_LIMITER_PUBLIC], true)) return; |
|
| 148 | + if (!in_array($limiter, [CACHE_LIMITER_PRIVATE, CACHE_LIMITER_PUBLIC], true)) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 145 | 151 | |
| 146 | 152 | header('Expires: ' . gmdate('D, d M Y H:i:s', (REQUEST_TIME + $expires)) . ' GMT'); |
| 147 | 153 | |
@@ -160,7 +166,9 @@ discard block |
||
| 160 | 166 | |
| 161 | 167 | public static function nocache() { |
| 162 | 168 | |
| 163 | - if (self::$cache_send) return; |
|
| 169 | + if (self::$cache_send) { |
|
| 170 | + return; |
|
| 171 | + } |
|
| 164 | 172 | |
| 165 | 173 | header('Expires: ' . gmdate('D, d M Y H:i:s', strtotime('-1 day')) . ' GMT'); |
| 166 | 174 | |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | public static function status(string $code) { |
| 119 | 119 | |
| 120 | - if (self::isStatusCode($code)) header(getenv('SERVER_PROTOCOL') . ' ' . self::$status_codes[$code]); |
|
| 120 | + if (self::isStatusCode($code)) header(getenv('SERVER_PROTOCOL').' '.self::$status_codes[$code]); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | # Send content header |
@@ -126,12 +126,12 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | if (self::isContentTypeText($type)) { |
| 128 | 128 | |
| 129 | - return header('Content-type: ' . self::$content_types_text[$type] . '; charset=UTF-8'); |
|
| 129 | + return header('Content-type: '.self::$content_types_text[$type].'; charset=UTF-8'); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | if (self::isContentTypeMedia($type)) { |
| 133 | 133 | |
| 134 | - return header('Content-type: ' . self::$content_types_media[$type]); |
|
| 134 | + return header('Content-type: '.self::$content_types_media[$type]); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -143,13 +143,13 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | if (!in_array($limiter, [CACHE_LIMITER_PRIVATE, CACHE_LIMITER_PUBLIC], true)) return; |
| 145 | 145 | |
| 146 | - header('Expires: ' . gmdate('D, d M Y H:i:s', (REQUEST_TIME + $expires)) . ' GMT'); |
|
| 146 | + header('Expires: '.gmdate('D, d M Y H:i:s', (REQUEST_TIME + $expires)).' GMT'); |
|
| 147 | 147 | |
| 148 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', REQUEST_TIME) . ' GMT'); |
|
| 148 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', REQUEST_TIME).' GMT'); |
|
| 149 | 149 | |
| 150 | - header('Cache-Control: ' . $limiter . ', max-age=' . $expires . ', pre-check=' . $expires); |
|
| 150 | + header('Cache-Control: '.$limiter.', max-age='.$expires.', pre-check='.$expires); |
|
| 151 | 151 | |
| 152 | - header('Pragma: ' . $limiter); |
|
| 152 | + header('Pragma: '.$limiter); |
|
| 153 | 153 | |
| 154 | 154 | # ------------------------ |
| 155 | 155 | |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | if (self::$cache_send) return; |
| 164 | 164 | |
| 165 | - header('Expires: ' . gmdate('D, d M Y H:i:s', strtotime('-1 day')) . ' GMT'); |
|
| 165 | + header('Expires: '.gmdate('D, d M Y H:i:s', strtotime('-1 day')).' GMT'); |
|
| 166 | 166 | |
| 167 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', strtotime('-1 day')) . ' GMT'); |
|
| 167 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', strtotime('-1 day')).' GMT'); |
|
| 168 | 168 | |
| 169 | 169 | header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); |
| 170 | 170 | |
@@ -10,14 +10,18 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | foreach (($string = explode("\n", $string)) as $key => $line) { |
| 12 | 12 | |
| 13 | - if ($multiline && $codestyle) $string[$key] = rtrim(preg_replace('/[\r\0\x0B]+/', '', $line)); |
|
| 14 | - |
|
| 15 | - else $string[$key] = trim(preg_replace(['/[ \t]+/', '/[\r\0\x0B]+/'], [' ', ''], $line)); |
|
| 13 | + if ($multiline && $codestyle) { |
|
| 14 | + $string[$key] = rtrim(preg_replace('/[\r\0\x0B]+/', '', $line)); |
|
| 15 | + } else { |
|
| 16 | + $string[$key] = trim(preg_replace(['/[ \t]+/', '/[\r\0\x0B]+/'], [' ', ''], $line)); |
|
| 17 | + } |
|
| 16 | 18 | } |
| 17 | 19 | |
| 18 | - if (!$multiline) $string = preg_replace('/ {2,}/', ' ', trim(implode(' ', $string), ' ')); |
|
| 19 | - |
|
| 20 | - else $string = preg_replace('/(\r\n){3,}/', "\r\n\r\n", trim(implode("\r\n", $string), "\r\n")); |
|
| 20 | + if (!$multiline) { |
|
| 21 | + $string = preg_replace('/ {2,}/', ' ', trim(implode(' ', $string), ' ')); |
|
| 22 | + } else { |
|
| 23 | + $string = preg_replace('/(\r\n){3,}/', "\r\n\r\n", trim(implode("\r\n", $string), "\r\n")); |
|
| 24 | + } |
|
| 21 | 25 | |
| 22 | 26 | # ------------------------ |
| 23 | 27 | |
@@ -136,7 +140,9 @@ discard block |
||
| 136 | 140 | |
| 137 | 141 | public static function cut(string $string, int $maxlength, bool $ellipsis = false) { |
| 138 | 142 | |
| 139 | - if (($maxlength < 1) || (self::length($string = trim($string)) <= $maxlength)) return $string; |
|
| 143 | + if (($maxlength < 1) || (self::length($string = trim($string)) <= $maxlength)) { |
|
| 144 | + return $string; |
|
| 145 | + } |
|
| 140 | 146 | |
| 141 | 147 | $string = (rtrim(self::substr($string, 0, $maxlength)) . ($ellipsis ? '...' : '')); |
| 142 | 148 | |
@@ -149,9 +155,13 @@ discard block |
||
| 149 | 155 | |
| 150 | 156 | public static function random(int $length, string $pool = STR_POOL_DEFAULT) { |
| 151 | 157 | |
| 152 | - if (($length < 1) || (0 === ($pool_length = self::length($pool)))) return ''; |
|
| 158 | + if (($length < 1) || (0 === ($pool_length = self::length($pool)))) { |
|
| 159 | + return ''; |
|
| 160 | + } |
|
| 153 | 161 | |
| 154 | - $string = ''; for ($i = 0; $i < $length; $i++) $string .= self::substr($pool, random_int(0, ($pool_length - 1)), 1); |
|
| 162 | + $string = ''; for ($i = 0; $i < $length; $i++) { |
|
| 163 | + $string .= self::substr($pool, random_int(0, ($pool_length - 1)), 1); |
|
| 164 | + } |
|
| 155 | 165 | |
| 156 | 166 | # ------------------------ |
| 157 | 167 | |
@@ -53,25 +53,25 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $pattern = [ |
| 55 | 55 | |
| 56 | - 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', |
|
| 57 | - 'Д' => 'D', 'Е' => 'E', 'Ж' => 'ZH', 'З' => 'Z', |
|
| 58 | - 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', |
|
| 59 | - 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', |
|
| 60 | - 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', |
|
| 61 | - 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', |
|
| 62 | - 'Ш' => 'SH', 'Щ' => 'SCH', 'Ъ' => '', 'Ь' => '', |
|
| 63 | - 'Ы' => 'Y', 'Э' => 'E', 'Ю' => 'JU', 'Я' => 'JA', |
|
| 64 | - 'І' => 'I', 'Ї' => 'JI', 'Ё' => 'JO', |
|
| 65 | - |
|
| 66 | - 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', |
|
| 67 | - 'д' => 'd', 'е' => 'e', 'ж' => 'zh', 'з' => 'z', |
|
| 68 | - 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', |
|
| 69 | - 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', |
|
| 70 | - 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', |
|
| 71 | - 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', |
|
| 72 | - 'ш' => 'sh', 'щ' => 'sch', 'ъ' => '', 'ь' => '', |
|
| 73 | - 'ы' => 'y', 'э' => 'e', 'ю' => 'ju', 'я' => 'ja', |
|
| 74 | - 'і' => 'i', 'ї' => 'ji', 'ё' => 'jo' |
|
| 56 | + 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', |
|
| 57 | + 'Д' => 'D', 'Е' => 'E', 'Ж' => 'ZH', 'З' => 'Z', |
|
| 58 | + 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', |
|
| 59 | + 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', |
|
| 60 | + 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', |
|
| 61 | + 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', |
|
| 62 | + 'Ш' => 'SH', 'Щ' => 'SCH', 'Ъ' => '', 'Ь' => '', |
|
| 63 | + 'Ы' => 'Y', 'Э' => 'E', 'Ю' => 'JU', 'Я' => 'JA', |
|
| 64 | + 'І' => 'I', 'Ї' => 'JI', 'Ё' => 'JO', |
|
| 65 | + |
|
| 66 | + 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', |
|
| 67 | + 'д' => 'd', 'е' => 'e', 'ж' => 'zh', 'з' => 'z', |
|
| 68 | + 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', |
|
| 69 | + 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', |
|
| 70 | + 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', |
|
| 71 | + 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', |
|
| 72 | + 'ш' => 'sh', 'щ' => 'sch', 'ъ' => '', 'ь' => '', |
|
| 73 | + 'ы' => 'y', 'э' => 'e', 'ю' => 'ju', 'я' => 'ja', |
|
| 74 | + 'і' => 'i', 'ї' => 'ji', 'ё' => 'jo' |
|
| 75 | 75 | ]; |
| 76 | 76 | |
| 77 | 77 | # ------------------------ |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | if (($maxlength < 1) || (self::length($string = trim($string)) <= $maxlength)) return $string; |
| 140 | 140 | |
| 141 | - $string = (rtrim(self::substr($string, 0, $maxlength)) . ($ellipsis ? '...' : '')); |
|
| 141 | + $string = (rtrim(self::substr($string, 0, $maxlength)).($ellipsis ? '...' : '')); |
|
| 142 | 142 | |
| 143 | 143 | # ------------------------ |
| 144 | 144 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | public static function encode(string $key, string $string) { |
| 164 | 164 | |
| 165 | - return sha1($key . substr(sha1($string), 8, 32)); |
|
| 165 | + return sha1($key.substr(sha1($string), 8, 32)); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -10,9 +10,13 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | private static function search(array &$list) { |
| 12 | 12 | |
| 13 | - if (empty($agent = getenv('HTTP_USER_AGENT'))) return false; |
|
| 13 | + if (empty($agent = getenv('HTTP_USER_AGENT'))) { |
|
| 14 | + return false; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | - foreach ($list as $item) if (false !== stripos($agent, $item)) return true; |
|
| 17 | + foreach ($list as $item) { |
|
| 18 | + if (false !== stripos($agent, $item)) return true; |
|
| 19 | + } |
|
| 16 | 20 | |
| 17 | 21 | # ------------------------ |
| 18 | 22 | |
@@ -27,9 +31,13 @@ discard block |
||
| 27 | 31 | |
| 28 | 32 | $file_robots = (DIR_DATA . 'Agent/Robots.php'); |
| 29 | 33 | |
| 30 | - if (is_array($mobiles = Explorer::php($file_mobiles))) self::$mobiles = $mobiles; |
|
| 34 | + if (is_array($mobiles = Explorer::php($file_mobiles))) { |
|
| 35 | + self::$mobiles = $mobiles; |
|
| 36 | + } |
|
| 31 | 37 | |
| 32 | - if (is_array($robots = Explorer::php($file_robots))) self::$robots = $robots; |
|
| 38 | + if (is_array($robots = Explorer::php($file_robots))) { |
|
| 39 | + self::$robots = $robots; |
|
| 40 | + } |
|
| 33 | 41 | } |
| 34 | 42 | |
| 35 | 43 | # Check if user agent is mobile |
@@ -23,9 +23,9 @@ |
||
| 23 | 23 | |
| 24 | 24 | public static function __autoload() { |
| 25 | 25 | |
| 26 | - $file_mobiles = (DIR_DATA . 'Agent/Mobiles.php'); |
|
| 26 | + $file_mobiles = (DIR_DATA.'Agent/Mobiles.php'); |
|
| 27 | 27 | |
| 28 | - $file_robots = (DIR_DATA . 'Agent/Robots.php'); |
|
| 28 | + $file_robots = (DIR_DATA.'Agent/Robots.php'); |
|
| 29 | 29 | |
| 30 | 30 | if (is_array($mobiles = Explorer::php($file_mobiles))) self::$mobiles = $mobiles; |
| 31 | 31 | |
@@ -8,11 +8,17 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | public static function format($number, int $min = 0, int $max = 0) { |
| 10 | 10 | |
| 11 | - if (!is_numeric($number) || (($number = intval($number)) < 0)) $number = 0; |
|
| 11 | + if (!is_numeric($number) || (($number = intval($number)) < 0)) { |
|
| 12 | + $number = 0; |
|
| 13 | + } |
|
| 12 | 14 | |
| 13 | - if (($min > 0) && ($number < $min)) return $min; |
|
| 15 | + if (($min > 0) && ($number < $min)) { |
|
| 16 | + return $min; |
|
| 17 | + } |
|
| 14 | 18 | |
| 15 | - if (($max > 0) && ($number > $max)) return $max; |
|
| 19 | + if (($max > 0) && ($number > $max)) { |
|
| 20 | + return $max; |
|
| 21 | + } |
|
| 16 | 22 | |
| 17 | 23 | # ------------------------ |
| 18 | 24 | |
@@ -23,11 +29,17 @@ discard block |
||
| 23 | 29 | |
| 24 | 30 | public static function formatFloat($number, float $min = 0, float $max = 0, int $decimals = 0) { |
| 25 | 31 | |
| 26 | - if (!is_numeric($number) || (($number = floatval($number)) < 0)) $number = 0; |
|
| 32 | + if (!is_numeric($number) || (($number = floatval($number)) < 0)) { |
|
| 33 | + $number = 0; |
|
| 34 | + } |
|
| 27 | 35 | |
| 28 | - if (($min > 0) && ($number < $min)) $number = $min; |
|
| 36 | + if (($min > 0) && ($number < $min)) { |
|
| 37 | + $number = $min; |
|
| 38 | + } |
|
| 29 | 39 | |
| 30 | - if (($max > 0) && ($number > $max)) $number = $max; |
|
| 40 | + if (($max > 0) && ($number > $max)) { |
|
| 41 | + $number = $max; |
|
| 42 | + } |
|
| 31 | 43 | |
| 32 | 44 | $number = floatval(number_format($number, $decimals, '.', '')); |
| 33 | 45 | |
@@ -42,9 +54,11 @@ discard block |
||
| 42 | 54 | |
| 43 | 55 | $number = (($number >= 0) ? $number : 0); $exponents = [0 => 'Bytes', 'KB', 'MB', 'GB', 'TB']; |
| 44 | 56 | |
| 45 | - foreach ($exponents as $exponent => $text) if ($number < pow(1024, ($exponent + 1))) { |
|
| 57 | + foreach ($exponents as $exponent => $text) { |
|
| 58 | + if ($number < pow(1024, ($exponent + 1))) { |
|
| 46 | 59 | |
| 47 | 60 | $number = number_format(($number / pow(1024, $exponent)), (($exponent < 2) ? $exponent : 2)); |
| 61 | + } |
|
| 48 | 62 | |
| 49 | 63 | return (floatval($number) . ' ' . $text); |
| 50 | 64 | } |
@@ -62,13 +76,21 @@ discard block |
||
| 62 | 76 | |
| 63 | 77 | $last_1 = substr($number, ($length - 1), 1); $last_2 = substr($number, ($length - 2), 2); |
| 64 | 78 | |
| 65 | - if (($last_2 >= 11) && ($last_2 <= 20)) return $variant_5; |
|
| 79 | + if (($last_2 >= 11) && ($last_2 <= 20)) { |
|
| 80 | + return $variant_5; |
|
| 81 | + } |
|
| 66 | 82 | |
| 67 | - if ($last_1 == 1) return $variant_1; |
|
| 83 | + if ($last_1 == 1) { |
|
| 84 | + return $variant_1; |
|
| 85 | + } |
|
| 68 | 86 | |
| 69 | - if (($last_1 >= 2) && ($last_1 <= 4)) return $variant_3; |
|
| 87 | + if (($last_1 >= 2) && ($last_1 <= 4)) { |
|
| 88 | + return $variant_3; |
|
| 89 | + } |
|
| 70 | 90 | |
| 71 | - if (($last_1 >= 5) || ($last_1 == 0)) return $variant_5; |
|
| 91 | + if (($last_1 >= 5) || ($last_1 == 0)) { |
|
| 92 | + return $variant_5; |
|
| 93 | + } |
|
| 72 | 94 | } |
| 73 | 95 | } |
| 74 | 96 | } |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | |
| 47 | 47 | $number = number_format(($number / pow(1024, $exponent)), (($exponent < 2) ? $exponent : 2)); |
| 48 | 48 | |
| 49 | - return (floatval($number) . ' ' . $text); |
|
| 49 | + return (floatval($number).' '.$text); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | # ------------------------ |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | private function addField(Form\Utils\Field $field) { |
| 12 | 12 | |
| 13 | - if ($this->posted || ('' === ($key = $field->key()))) return false; |
|
| 13 | + if ($this->posted || ('' === ($key = $field->key()))) { |
|
| 14 | + return false; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | 17 | $this->fields[$key] = $field; |
| 16 | 18 | |
@@ -23,7 +25,9 @@ discard block |
||
| 23 | 25 | |
| 24 | 26 | public function __construct(string $name = '') { |
| 25 | 27 | |
| 26 | - if (preg_match(REGEX_FORM_NAME, $name)) $this->name = $name; |
|
| 28 | + if (preg_match(REGEX_FORM_NAME, $name)) { |
|
| 29 | + $this->name = $name; |
|
| 30 | + } |
|
| 27 | 31 | } |
| 28 | 32 | |
| 29 | 33 | # Add text field |
@@ -65,9 +69,15 @@ discard block |
||
| 65 | 69 | |
| 66 | 70 | foreach ($this->fields as $field) { |
| 67 | 71 | |
| 68 | - if (($field instanceof Form\Field\Checkbox) || $field->disabled()) continue; |
|
| 72 | + if (($field instanceof Form\Field\Checkbox) || $field->disabled()) { |
|
| 73 | + continue; |
|
| 74 | + } |
|
| 69 | 75 | |
| 70 | - if (false !== Request::post($field->name())) $check = true; else return false; |
|
| 76 | + if (false !== Request::post($field->name())) { |
|
| 77 | + $check = true; |
|
| 78 | + } else { |
|
| 79 | + return false; |
|
| 80 | + } |
|
| 71 | 81 | } |
| 72 | 82 | |
| 73 | 83 | # ------------------------ |
@@ -79,7 +89,9 @@ discard block |
||
| 79 | 89 | |
| 80 | 90 | public function post() { |
| 81 | 91 | |
| 82 | - if ($this->posted || !$this->check()) return false; |
|
| 92 | + if ($this->posted || !$this->check()) { |
|
| 93 | + return false; |
|
| 94 | + } |
|
| 83 | 95 | |
| 84 | 96 | $errors = false; $post = []; |
| 85 | 97 | |
@@ -87,7 +99,9 @@ discard block |
||
| 87 | 99 | |
| 88 | 100 | $field->post(); $post[$field->key()] = $field->value(); |
| 89 | 101 | |
| 90 | - if ($field->error()) $errors = true; |
|
| 102 | + if ($field->error()) { |
|
| 103 | + $errors = true; |
|
| 104 | + } |
|
| 91 | 105 | } |
| 92 | 106 | |
| 93 | 107 | $this->posted = true; $this->errors = $errors; |
@@ -131,7 +131,7 @@ |
||
| 131 | 131 | |
| 132 | 132 | foreach ($this->fields as $field) { |
| 133 | 133 | |
| 134 | - $block->block(('field_' . $field->name()), $field->block()); |
|
| 134 | + $block->block(('field_'.$field->name()), $field->block()); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | |
| 45 | 45 | public function __construct(Form $form, string $key, string $value = '', |
| 46 | 46 | |
| 47 | - array $options = [], string $default = null, array $config = []) { |
|
| 47 | + array $options = [], string $default = null, array $config = []) { |
|
| 48 | 48 | |
| 49 | 49 | # Init field |
| 50 | 50 | |
@@ -92,9 +92,13 @@ |
||
| 92 | 92 | |
| 93 | 93 | $tag = $this->getTag('select'); |
| 94 | 94 | |
| 95 | - if ($this->config['search']) $tag->set('data-search', 'search'); |
|
| 95 | + if ($this->config['search']) { |
|
| 96 | + $tag->set('data-search', 'search'); |
|
| 97 | + } |
|
| 96 | 98 | |
| 97 | - if ($this->config['auto']) $tag->set('data-auto', 'auto'); |
|
| 99 | + if ($this->config['auto']) { |
|
| 100 | + $tag->set('data-auto', 'auto'); |
|
| 101 | + } |
|
| 98 | 102 | |
| 99 | 103 | $tag->contents($this->getOptions()); |
| 100 | 104 | |