@@ -24,11 +24,17 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | # Set config |
| 26 | 26 | |
| 27 | - if ($this->disabled) $tag->set('disabled', 'disabled'); |
|
| 27 | + if ($this->disabled) { |
|
| 28 | + $tag->set('disabled', 'disabled'); |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | - if ($this->required) $tag->set('data-required', 'required'); |
|
| 31 | + if ($this->required) { |
|
| 32 | + $tag->set('data-required', 'required'); |
|
| 33 | + } |
|
| 30 | 34 | |
| 31 | - if ($this->error) $tag->set('data-error', 'error'); |
|
| 35 | + if ($this->error) { |
|
| 36 | + $tag->set('data-error', 'error'); |
|
| 37 | + } |
|
| 32 | 38 | |
| 33 | 39 | # ------------------------ |
| 34 | 40 | |
@@ -54,9 +60,12 @@ discard block |
||
| 54 | 60 | |
| 55 | 61 | $params = array_merge(['disabled' => false, 'required' => false], $this->config); |
| 56 | 62 | |
| 57 | - foreach ($params as $name => $default) if (isset($config[$name])) { |
|
| 63 | + foreach ($params as $name => $default) { |
|
| 64 | + if (isset($config[$name])) { |
|
| 58 | 65 | |
| 59 | - try { $this->$name($config[$name]); } catch (\TypeError $e) {} |
|
| 66 | + try { $this->$name($config[$name]); |
|
| 67 | + } |
|
| 68 | + } catch (\TypeError $e) {} |
|
| 60 | 69 | } |
| 61 | 70 | } |
| 62 | 71 | |
@@ -64,7 +73,9 @@ discard block |
||
| 64 | 73 | |
| 65 | 74 | public function post() { |
| 66 | 75 | |
| 67 | - if ($this->posted || $this->disabled || ('' === $this->key)) return false; |
|
| 76 | + if ($this->posted || $this->disabled || ('' === $this->key)) { |
|
| 77 | + return false; |
|
| 78 | + } |
|
| 68 | 79 | |
| 69 | 80 | $this->error = (!$this->set(Request::post($this->name)) && $this->required); |
| 70 | 81 | |
@@ -98,7 +109,9 @@ discard block |
||
| 98 | 109 | |
| 99 | 110 | public function disabled(bool $value = null) { |
| 100 | 111 | |
| 101 | - if (null === $value) return $this->disabled; |
|
| 112 | + if (null === $value) { |
|
| 113 | + return $this->disabled; |
|
| 114 | + } |
|
| 102 | 115 | |
| 103 | 116 | $this->disabled = $value; |
| 104 | 117 | } |
@@ -107,7 +120,9 @@ discard block |
||
| 107 | 120 | |
| 108 | 121 | public function required(bool $value = null) { |
| 109 | 122 | |
| 110 | - if (null === $value) return $this->required; |
|
| 123 | + if (null === $value) { |
|
| 124 | + return $this->required; |
|
| 125 | + } |
|
| 111 | 126 | |
| 112 | 127 | $this->required = $value; |
| 113 | 128 | } |
@@ -116,7 +131,9 @@ discard block |
||
| 116 | 131 | |
| 117 | 132 | public function error(bool $value = null) { |
| 118 | 133 | |
| 119 | - if (null === $value) return $this->error; |
|
| 134 | + if (null === $value) { |
|
| 135 | + return $this->error; |
|
| 136 | + } |
|
| 120 | 137 | |
| 121 | 138 | $this->error = $value; |
| 122 | 139 | } |
@@ -10,7 +10,9 @@ |
||
| 10 | 10 | |
| 11 | 11 | protected static function init(string $file_name) { |
| 12 | 12 | |
| 13 | - if (is_array($range = Explorer::php($file_name))) static::$range = $range; |
|
| 13 | + if (is_array($range = Explorer::php($file_name))) { |
|
| 14 | + static::$range = $range; |
|
| 15 | + } |
|
| 14 | 16 | } |
| 15 | 17 | |
| 16 | 18 | # Check if item exists |
@@ -10,7 +10,12 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | $value = false; |
| 12 | 12 | |
| 13 | - foreach ($path as $item) if (isset($array[$item])) $value = ($array = $array[$item]); else return false; |
|
| 13 | + foreach ($path as $item) { |
|
| 14 | + if (isset($array[$item])) $value = ($array = $array[$item]); |
|
| 15 | + } |
|
| 16 | + else { |
|
| 17 | + return false; |
|
| 18 | + } |
|
| 14 | 19 | |
| 15 | 20 | # ------------------------ |
| 16 | 21 | |
@@ -23,10 +28,12 @@ discard block |
||
| 23 | 28 | |
| 24 | 29 | $result = []; |
| 25 | 30 | |
| 26 | - foreach ($keys as $key) if (is_scalar($key)) { |
|
| 31 | + foreach ($keys as $key) { |
|
| 32 | + if (is_scalar($key)) { |
|
| 27 | 33 | |
| 28 | 34 | $result[$key] = ((isset($array[$key]) && is_scalar($array[$key])) ? $array[$key] : false); |
| 29 | 35 | } |
| 36 | + } |
|
| 30 | 37 | |
| 31 | 38 | # ------------------------ |
| 32 | 39 | |
@@ -39,7 +46,9 @@ discard block |
||
| 39 | 46 | |
| 40 | 47 | $result = []; |
| 41 | 48 | |
| 42 | - foreach ($array as $key => $value) $result[] = [$key_name => $key, $value_name => $value]; |
|
| 49 | + foreach ($array as $key => $value) { |
|
| 50 | + $result[] = [$key_name => $key, $value_name => $value]; |
|
| 51 | + } |
|
| 43 | 52 | |
| 44 | 53 | # ------------------------ |
| 45 | 54 | |
@@ -57,9 +66,15 @@ discard block |
||
| 57 | 66 | |
| 58 | 67 | $result = []; $column = array_map($select_key, $array); |
| 59 | 68 | |
| 60 | - if (!$descending) asort($column); else arsort($column); |
|
| 69 | + if (!$descending) { |
|
| 70 | + asort($column); |
|
| 71 | + } else { |
|
| 72 | + arsort($column); |
|
| 73 | + } |
|
| 61 | 74 | |
| 62 | - foreach (array_keys($column) as $key) $result[$key] = $array[$key]; |
|
| 75 | + foreach (array_keys($column) as $key) { |
|
| 76 | + $result[$key] = $array[$key]; |
|
| 77 | + } |
|
| 63 | 78 | |
| 64 | 79 | # ------------------------ |
| 65 | 80 | |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | public function add(string $name, $default, callable $handler) { |
| 12 | 12 | |
| 13 | - if ('' === $name) return; |
|
| 13 | + if ('' === $name) { |
|
| 14 | + return; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | 17 | $this->config[$name] = $handler; $this->values[$name] = null; |
| 16 | 18 | |
@@ -23,11 +25,11 @@ discard block |
||
| 23 | 25 | |
| 24 | 26 | foreach ($data as $name => $value) { |
| 25 | 27 | |
| 26 | - if (!isset($this->config[$name])) continue; |
|
| 27 | - |
|
| 28 | - try { $this->values[$name] = $this->config[$name]($value); } |
|
| 28 | + if (!isset($this->config[$name])) { |
|
| 29 | + continue; |
|
| 30 | + } |
|
| 29 | 31 | |
| 30 | - catch (\TypeError $e) {} |
|
| 32 | + try { $this->values[$name] = $this->config[$name]($value); } catch (\TypeError $e) {} |
|
| 31 | 33 | } |
| 32 | 34 | } |
| 33 | 35 | |
@@ -39,11 +41,11 @@ discard block |
||
| 39 | 41 | |
| 40 | 42 | foreach ($this->config as $name => $handler) { |
| 41 | 43 | |
| 42 | - if (!($isset = isset($data[$name])) && !$process_all) continue; |
|
| 44 | + if (!($isset = isset($data[$name])) && !$process_all) { |
|
| 45 | + continue; |
|
| 46 | + } |
|
| 43 | 47 | |
| 44 | - try { $cast[$name] = ($isset ? $handler($data[$name]) : $this->values[$name]); } |
|
| 45 | - |
|
| 46 | - catch (\TypeError $e) { $cast[$name] = $this->values[$name]; } |
|
| 48 | + try { $cast[$name] = ($isset ? $handler($data[$name]) : $this->values[$name]); } catch (\TypeError $e) { $cast[$name] = $this->values[$name]; } |
|
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | # ------------------------ |
@@ -55,7 +57,9 @@ discard block |
||
| 55 | 57 | |
| 56 | 58 | public function get(string $name = null) { |
| 57 | 59 | |
| 58 | - if (null === $name) return $this->values; |
|
| 60 | + if (null === $name) { |
|
| 61 | + return $this->values; |
|
| 62 | + } |
|
| 59 | 63 | |
| 60 | 64 | return ($this->values[$name] ?? null); |
| 61 | 65 | } |
@@ -10,7 +10,9 @@ |
||
| 10 | 10 | |
| 11 | 11 | public function set(string $name, $value) { |
| 12 | 12 | |
| 13 | - if (is_scalar($value)) $this->data[$name] = $value; |
|
| 13 | + if (is_scalar($value)) { |
|
| 14 | + $this->data[$name] = $value; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | 17 | return $this; |
| 16 | 18 | } |
@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | $item->children = ($children = Template::group()); |
| 22 | 22 | |
| 23 | - foreach ($this->menu[$id]['children'] as $child) $children->add($this->parseItem($child)); |
|
| 23 | + foreach ($this->menu[$id]['children'] as $child) { |
|
| 24 | + $children->add($this->parseItem($child)); |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | } else { |
| 26 | 28 | |
@@ -44,7 +46,9 @@ discard block |
||
| 44 | 46 | |
| 45 | 47 | $menu = Entitizer::treeview(TABLE_MENU)->subtree(0, ['active' => true]); |
| 46 | 48 | |
| 47 | - if (false !== $menu) $this->menu = $menu; |
|
| 49 | + if (false !== $menu) { |
|
| 50 | + $this->menu = $menu; |
|
| 51 | + } |
|
| 48 | 52 | } |
| 49 | 53 | |
| 50 | 54 | # Get block |
@@ -53,7 +57,9 @@ discard block |
||
| 53 | 57 | |
| 54 | 58 | $menu = Template::group(); |
| 55 | 59 | |
| 56 | - foreach ($this->menu[0]['children'] as $id) $menu->add($this->parseItem($id)); |
|
| 60 | + foreach ($this->menu[0]['children'] as $id) { |
|
| 61 | + $menu->add($this->parseItem($id)); |
|
| 62 | + } |
|
| 57 | 63 | |
| 58 | 64 | # ------------------------ |
| 59 | 65 | |
@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public static function set(string $type, string $text, string $title = null) { |
| 23 | 23 | |
| 24 | - if (!in_array($type, static::$types, true) || isset(static::$items[$type]) || ('' === $text)) return; |
|
| 24 | + if (!in_array($type, static::$types, true) || isset(static::$items[$type]) || ('' === $text)) { |
|
| 25 | + return; |
|
| 26 | + } |
|
| 25 | 27 | |
| 26 | 28 | static::$items[$type] = ['text' => $text, 'title' => (('' !== $title) ? $title : null)]; |
| 27 | 29 | } |
@@ -45,7 +47,9 @@ discard block |
||
| 45 | 47 | |
| 46 | 48 | $block->type = $type; $block->text = Template::block($item['text']); |
| 47 | 49 | |
| 48 | - if (isset($item['title'])) $block->block('title')->set('text', $item['title'])->enable(); |
|
| 50 | + if (isset($item['title'])) { |
|
| 51 | + $block->block('title')->set('text', $item['title'])->enable(); |
|
| 52 | + } |
|
| 49 | 53 | } |
| 50 | 54 | |
| 51 | 55 | # ------------------------ |
@@ -14,11 +14,15 @@ |
||
| 14 | 14 | |
| 15 | 15 | $selection = ['name', 'value']; $order = ['name' => 'ASC']; |
| 16 | 16 | |
| 17 | - if (!(DB::select(TABLE_VARIABLES, $selection, null, $order) && DB::last()->status)) return; |
|
| 17 | + if (!(DB::select(TABLE_VARIABLES, $selection, null, $order) && DB::last()->status)) { |
|
| 18 | + return; |
|
| 19 | + } |
|
| 18 | 20 | |
| 19 | 21 | # Process results |
| 20 | 22 | |
| 21 | - while (null !== ($variable = DB::last()->row())) yield $variable['name'] => $variable['value']; |
|
| 23 | + while (null !== ($variable = DB::last()->row())) { |
|
| 24 | + yield $variable['name'] => $variable['value']; |
|
| 25 | + } |
|
| 22 | 26 | } |
| 23 | 27 | } |
| 24 | 28 | } |
@@ -14,11 +14,15 @@ |
||
| 14 | 14 | |
| 15 | 15 | $selection = ['name', 'contents']; $condition = ['active' => 1]; $order = ['name' => 'ASC']; |
| 16 | 16 | |
| 17 | - if (!(DB::select(TABLE_WIDGETS, $selection, $condition, $order) && DB::last()->status)) return; |
|
| 17 | + if (!(DB::select(TABLE_WIDGETS, $selection, $condition, $order) && DB::last()->status)) { |
|
| 18 | + return; |
|
| 19 | + } |
|
| 18 | 20 | |
| 19 | 21 | # Process results |
| 20 | 22 | |
| 21 | - while (null !== ($widget = DB::last()->row())) yield $widget['name'] => Template::block($widget['contents']); |
|
| 23 | + while (null !== ($widget = DB::last()->row())) { |
|
| 24 | + yield $widget['name'] => Template::block($widget['contents']); |
|
| 25 | + } |
|
| 22 | 26 | } |
| 23 | 27 | } |
| 24 | 28 | } |