@@ -105,7 +105,7 @@ |
||
105 | 105 | |
106 | 106 | public function __construct(Form $form, string $key, string $value = '', |
107 | 107 | |
108 | - string $type = FORM_FIELD_TEXT, int $maxlength = 0, array $config = []) { |
|
108 | + string $type = FORM_FIELD_TEXT, int $maxlength = 0, array $config = []) { |
|
109 | 109 | |
110 | 110 | # Init field |
111 | 111 |
@@ -65,9 +65,13 @@ discard block |
||
65 | 65 | |
66 | 66 | $tag = $this->getTag('textarea', [], $this->value); |
67 | 67 | |
68 | - if ($this->config['rows'] > 0) $tag->set('rows', $this->config['rows']); |
|
68 | + if ($this->config['rows'] > 0) { |
|
69 | + $tag->set('rows', $this->config['rows']); |
|
70 | + } |
|
69 | 71 | |
70 | - if ($this->config['cols'] > 0) $tag->set('cols', $this->config['cols']); |
|
72 | + if ($this->config['cols'] > 0) { |
|
73 | + $tag->set('cols', $this->config['cols']); |
|
74 | + } |
|
71 | 75 | |
72 | 76 | # ------------------------ |
73 | 77 | |
@@ -78,27 +82,33 @@ discard block |
||
78 | 82 | |
79 | 83 | private function processSpaces() { |
80 | 84 | |
81 | - if ($this->config['spaces'] === 'strip') $this->value = Str::stripSpaces($this->value); |
|
82 | - |
|
83 | - else if ($this->config['spaces'] === 'single') $this->value = Str::singleSpaces($this->value); |
|
85 | + if ($this->config['spaces'] === 'strip') { |
|
86 | + $this->value = Str::stripSpaces($this->value); |
|
87 | + } else if ($this->config['spaces'] === 'single') { |
|
88 | + $this->value = Str::singleSpaces($this->value); |
|
89 | + } |
|
84 | 90 | } |
85 | 91 | |
86 | 92 | # Process convert |
87 | 93 | |
88 | 94 | private function processConvert() { |
89 | 95 | |
90 | - if ($this->config['convert'] === 'url') $this->value = Str::toUrl($this->value, $this->maxlength); |
|
91 | - |
|
92 | - else if ($this->config['convert'] === 'var') $this->value = Str::toVar($this->value, $this->maxlength); |
|
96 | + if ($this->config['convert'] === 'url') { |
|
97 | + $this->value = Str::toUrl($this->value, $this->maxlength); |
|
98 | + } else if ($this->config['convert'] === 'var') { |
|
99 | + $this->value = Str::toVar($this->value, $this->maxlength); |
|
100 | + } |
|
93 | 101 | } |
94 | 102 | |
95 | 103 | # Process transform |
96 | 104 | |
97 | 105 | private function processTransform() { |
98 | 106 | |
99 | - if ($this->config['transform'] === 'lower') $this->value = Str::toLower($this->value); |
|
100 | - |
|
101 | - else if ($this->config['transform'] === 'upper') $this->value = Str::toUpper($this->value); |
|
107 | + if ($this->config['transform'] === 'lower') { |
|
108 | + $this->value = Str::toLower($this->value); |
|
109 | + } else if ($this->config['transform'] === 'upper') { |
|
110 | + $this->value = Str::toUpper($this->value); |
|
111 | + } |
|
102 | 112 | } |
103 | 113 | |
104 | 114 | # Constructor |
@@ -164,7 +174,9 @@ discard block |
||
164 | 174 | |
165 | 175 | public function spaces(string $value) { |
166 | 176 | |
167 | - if (!in_array($value, ['strip', 'single'], true)) $value = ''; |
|
177 | + if (!in_array($value, ['strip', 'single'], true)) { |
|
178 | + $value = ''; |
|
179 | + } |
|
168 | 180 | |
169 | 181 | $this->config['spaces'] = $value; |
170 | 182 | } |
@@ -173,7 +185,9 @@ discard block |
||
173 | 185 | |
174 | 186 | public function convert(string $value) { |
175 | 187 | |
176 | - if (!in_array($value, ['url', 'var'], true)) $value = ''; |
|
188 | + if (!in_array($value, ['url', 'var'], true)) { |
|
189 | + $value = ''; |
|
190 | + } |
|
177 | 191 | |
178 | 192 | $this->config['convert'] = $value; |
179 | 193 | } |
@@ -182,7 +196,9 @@ discard block |
||
182 | 196 | |
183 | 197 | public function transform(string $value) { |
184 | 198 | |
185 | - if (!in_array($value, ['upper', 'lower'], true)) $value = ''; |
|
199 | + if (!in_array($value, ['upper', 'lower'], true)) { |
|
200 | + $value = ''; |
|
201 | + } |
|
186 | 202 | |
187 | 203 | $this->config['transform'] = $value; |
188 | 204 | } |
@@ -226,25 +242,35 @@ discard block |
||
226 | 242 | |
227 | 243 | public function block() { |
228 | 244 | |
229 | - if ($this->type === FORM_FIELD_HIDDEN) return $this->getHidden()->block(); |
|
230 | - |
|
231 | - else if ($this->type === FORM_FIELD_PASSWORD) $tag = $this->getPassword(); |
|
232 | - |
|
233 | - else if ($this->type === FORM_FIELD_CAPTCHA) $tag = $this->getCaptcha(); |
|
234 | - |
|
235 | - else if ($this->type === FORM_FIELD_TEXTAREA) $tag = $this->getTextarea(); |
|
236 | - |
|
237 | - else $tag = $this->getText(); |
|
245 | + if ($this->type === FORM_FIELD_HIDDEN) { |
|
246 | + return $this->getHidden()->block(); |
|
247 | + } else if ($this->type === FORM_FIELD_PASSWORD) { |
|
248 | + $tag = $this->getPassword(); |
|
249 | + } else if ($this->type === FORM_FIELD_CAPTCHA) { |
|
250 | + $tag = $this->getCaptcha(); |
|
251 | + } else if ($this->type === FORM_FIELD_TEXTAREA) { |
|
252 | + $tag = $this->getTextarea(); |
|
253 | + } else { |
|
254 | + $tag = $this->getText(); |
|
255 | + } |
|
238 | 256 | |
239 | 257 | # Set appearance |
240 | 258 | |
241 | - if ($this->maxlength > 0) $tag->set('maxlength', $this->maxlength); |
|
259 | + if ($this->maxlength > 0) { |
|
260 | + $tag->set('maxlength', $this->maxlength); |
|
261 | + } |
|
242 | 262 | |
243 | - if ('' !== $this->config['placeholder']) $tag->set('placeholder', $this->config['placeholder']); |
|
263 | + if ('' !== $this->config['placeholder']) { |
|
264 | + $tag->set('placeholder', $this->config['placeholder']); |
|
265 | + } |
|
244 | 266 | |
245 | - if ($this->config['readonly']) $tag->set('readonly', 'readonly'); |
|
267 | + if ($this->config['readonly']) { |
|
268 | + $tag->set('readonly', 'readonly'); |
|
269 | + } |
|
246 | 270 | |
247 | - if ($this->config['autofocus']) $tag->set('autofocus', 'autofocus'); |
|
271 | + if ($this->config['autofocus']) { |
|
272 | + $tag->set('autofocus', 'autofocus'); |
|
273 | + } |
|
248 | 274 | |
249 | 275 | # ------------------------ |
250 | 276 |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | |
24 | 24 | $this->name = $name; |
25 | 25 | |
26 | - foreach ($attributes as $name => $value) $this->set($name, $value); |
|
26 | + foreach ($attributes as $name => $value) { |
|
27 | + $this->set($name, $value); |
|
28 | + } |
|
27 | 29 | |
28 | 30 | $this->contents($contents); |
29 | 31 | } |
@@ -41,9 +43,11 @@ discard block |
||
41 | 43 | |
42 | 44 | public function contents($contents) { |
43 | 45 | |
44 | - if ((null === $contents) || Template::isBlock($contents)) $this->contents = $contents; |
|
45 | - |
|
46 | - else if (is_scalar($contents)) $this->contents = Template::block('$contents$')->set('contents', $contents); |
|
46 | + if ((null === $contents) || Template::isBlock($contents)) { |
|
47 | + $this->contents = $contents; |
|
48 | + } else if (is_scalar($contents)) { |
|
49 | + $this->contents = Template::block('$contents$')->set('contents', $contents); |
|
50 | + } |
|
47 | 51 | |
48 | 52 | # ------------------------ |
49 | 53 |
@@ -8,9 +8,13 @@ discard block |
||
8 | 8 | |
9 | 9 | public static function validate(string $date, string $format) { |
10 | 10 | |
11 | - if (false === ($date_object = date_create_from_format($format, $date))) return false; |
|
11 | + if (false === ($date_object = date_create_from_format($format, $date))) { |
|
12 | + return false; |
|
13 | + } |
|
12 | 14 | |
13 | - if (false === ($date_formatted = $date_object->format($format))) return false; |
|
15 | + if (false === ($date_formatted = $date_object->format($format))) { |
|
16 | + return false; |
|
17 | + } |
|
14 | 18 | |
15 | 19 | # ------------------------ |
16 | 20 | |
@@ -35,7 +39,9 @@ discard block |
||
35 | 39 | |
36 | 40 | public static function validateYear(int $year) { |
37 | 41 | |
38 | - if (false === ($year = self::validate($year, 'Y'))) return false; |
|
42 | + if (false === ($year = self::validate($year, 'Y'))) { |
|
43 | + return false; |
|
44 | + } |
|
39 | 45 | |
40 | 46 | return (($year > '1900') ? (($year > self::year()) ? self::year() : $year) : '1900'); |
41 | 47 | } |
@@ -37,7 +37,9 @@ |
||
37 | 37 | |
38 | 38 | $group->add($block = clone($this->block)); |
39 | 39 | |
40 | - if (is_array($item)) foreach ($item as $name => $value) if (is_scalar($value)) $block->set($name, $value); |
|
40 | + if (is_array($item)) { |
|
41 | + foreach ($item as $name => $value) if (is_scalar($value)) $block->set($name, $value); |
|
42 | + } |
|
41 | 43 | } |
42 | 44 | |
43 | 45 | # ------------------------ |
@@ -23,7 +23,9 @@ |
||
23 | 23 | |
24 | 24 | $contents = ''; |
25 | 25 | |
26 | - foreach ($this->items as $block) $contents .= $block->contents(); |
|
26 | + foreach ($this->items as $block) { |
|
27 | + $contents .= $block->contents(); |
|
28 | + } |
|
27 | 29 | |
28 | 30 | # ------------------------ |
29 | 31 |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | |
9 | 9 | public static function start(string $name, int $lifetime) { |
10 | 10 | |
11 | - if (session_id()) return true; |
|
11 | + if (session_id()) { |
|
12 | + return true; |
|
13 | + } |
|
12 | 14 | |
13 | 15 | ini_set('session.gc_maxlifetime', $lifetime); |
14 | 16 | |
@@ -46,14 +48,18 @@ discard block |
||
46 | 48 | |
47 | 49 | public static function set(string $name, $value) { |
48 | 50 | |
49 | - if (session_id()) $_SESSION[$name] = $value; |
|
51 | + if (session_id()) { |
|
52 | + $_SESSION[$name] = $value; |
|
53 | + } |
|
50 | 54 | } |
51 | 55 | |
52 | 56 | # Delete variable |
53 | 57 | |
54 | 58 | public static function delete(string $name) { |
55 | 59 | |
56 | - if (session_id() && isset($_SESSION[$name])) unset($_SESSION[$name]); |
|
60 | + if (session_id() && isset($_SESSION[$name])) { |
|
61 | + unset($_SESSION[$name]); |
|
62 | + } |
|
57 | 63 | } |
58 | 64 | } |
59 | 65 | } |
@@ -31,7 +31,9 @@ |
||
31 | 31 | |
32 | 32 | public static function delete(string $name) { |
33 | 33 | |
34 | - if (isset($_COOKIE[$name])) unset($_COOKIE[$name]); |
|
34 | + if (isset($_COOKIE[$name])) { |
|
35 | + unset($_COOKIE[$name]); |
|
36 | + } |
|
35 | 37 | } |
36 | 38 | } |
37 | 39 | } |
@@ -10,7 +10,9 @@ |
||
10 | 10 | |
11 | 11 | private static function checkType(string $extension, string $type) { |
12 | 12 | |
13 | - if (false === ($mime = self::get($extension))) return false; |
|
13 | + if (false === ($mime = self::get($extension))) { |
|
14 | + return false; |
|
15 | + } |
|
14 | 16 | |
15 | 17 | return (preg_match('/^' . $type . '\//', $mime) ? true : false); |
16 | 18 | } |
@@ -12,14 +12,14 @@ |
||
12 | 12 | |
13 | 13 | if (false === ($mime = self::get($extension))) return false; |
14 | 14 | |
15 | - return (preg_match(('/^' . $type . '\//'), $mime) ? true : false); |
|
15 | + return (preg_match(('/^'.$type.'\//'), $mime) ? true : false); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | # Autoloader |
19 | 19 | |
20 | 20 | public static function __autoload() { |
21 | 21 | |
22 | - self::init(DIR_DATA . 'Mime.php'); |
|
22 | + self::init(DIR_DATA.'Mime.php'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | # Check if extension is image |
@@ -8,7 +8,9 @@ |
||
8 | 8 | |
9 | 9 | private static function output($image, string $mime, callable $outputter, array $params = []) { |
10 | 10 | |
11 | - if (!is_resource($image)) return false; |
|
11 | + if (!is_resource($image)) { |
|
12 | + return false; |
|
13 | + } |
|
12 | 14 | |
13 | 15 | Headers::nocache(); Headers::content($mime); |
14 | 16 |