@@ -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 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | |
| 21 | 21 | $toggle = (($matches[1][$key] === '!') ? 'disable' : 'enable'); |
| 22 | 22 | |
| 23 | - $type = $matches[2][$key]; $name = $matches[3][$key]; $contents = ($matches[4][$key] ?? ''); |
|
| 23 | + $type = $matches[2][$key]; $name = $matches[3][$key]; $contents = ($matches[4][$key] ? ? ''); |
|
| 24 | 24 | |
| 25 | 25 | if (!preg_match(REGEX_TEMPLATE_ITEM_NAME, $name)) continue; |
| 26 | 26 | |
@@ -22,15 +22,19 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | $type = $matches[2][$key]; $name = $matches[3][$key]; $contents = ($matches[4][$key] ?? ''); |
| 24 | 24 | |
| 25 | - if (!preg_match(REGEX_TEMPLATE_ITEM_NAME, $name)) continue; |
|
| 25 | + if (!preg_match(REGEX_TEMPLATE_ITEM_NAME, $name)) { |
|
| 26 | + continue; |
|
| 27 | + } |
|
| 26 | 28 | |
| 27 | 29 | $this->contents = str_replace($match, ('{ ' . $type . ':' . $name . ' / }'), $this->contents); |
| 28 | 30 | |
| 29 | - if ($type === 'block') $this->blocks[$name] = (new Block($contents))->$toggle(); |
|
| 30 | - |
|
| 31 | - else if ($type === 'for') $this->loops[$name] = new Loop($contents); |
|
| 32 | - |
|
| 33 | - else if ($type === 'widget') $this->widgets[] = $name; |
|
| 31 | + if ($type === 'block') { |
|
| 32 | + $this->blocks[$name] = (new Block($contents))->$toggle(); |
|
| 33 | + } else if ($type === 'for') { |
|
| 34 | + $this->loops[$name] = new Loop($contents); |
|
| 35 | + } else if ($type === 'widget') { |
|
| 36 | + $this->widgets[] = $name; |
|
| 37 | + } |
|
| 34 | 38 | } |
| 35 | 39 | } |
| 36 | 40 | |
@@ -48,7 +52,9 @@ discard block |
||
| 48 | 52 | |
| 49 | 53 | foreach ($matches[1] as $index => $name) { |
| 50 | 54 | |
| 51 | - if (!preg_match(REGEX_TEMPLATE_ITEM_NAME, $name)) continue; |
|
| 55 | + if (!preg_match(REGEX_TEMPLATE_ITEM_NAME, $name)) { |
|
| 56 | + continue; |
|
| 57 | + } |
|
| 52 | 58 | |
| 53 | 59 | $elementaries['stack'][$name] = false; |
| 54 | 60 | } |
@@ -68,29 +74,39 @@ discard block |
||
| 68 | 74 | |
| 69 | 75 | public function __clone() { |
| 70 | 76 | |
| 71 | - foreach ($this->blocks as $name => $block) $this->blocks[$name] = clone $block; |
|
| 77 | + foreach ($this->blocks as $name => $block) { |
|
| 78 | + $this->blocks[$name] = clone $block; |
|
| 79 | + } |
|
| 72 | 80 | |
| 73 | - foreach ($this->loops as $name => $loop) $this->loops[$name] = clone $loop; |
|
| 81 | + foreach ($this->loops as $name => $loop) { |
|
| 82 | + $this->loops[$name] = clone $loop; |
|
| 83 | + } |
|
| 74 | 84 | } |
| 75 | 85 | |
| 76 | 86 | # Setter |
| 77 | 87 | |
| 78 | 88 | public function __set(string $name, $value) { |
| 79 | 89 | |
| 80 | - if ($value instanceof Block) $this->block($name, $value); |
|
| 81 | - |
|
| 82 | - else if (is_array($value)) $this->loop($name, $value); |
|
| 83 | - |
|
| 84 | - else if (is_scalar($value)) $this->set($name, $value); |
|
| 90 | + if ($value instanceof Block) { |
|
| 91 | + $this->block($name, $value); |
|
| 92 | + } else if (is_array($value)) { |
|
| 93 | + $this->loop($name, $value); |
|
| 94 | + } else if (is_scalar($value)) { |
|
| 95 | + $this->set($name, $value); |
|
| 96 | + } |
|
| 85 | 97 | } |
| 86 | 98 | |
| 87 | 99 | # Set block |
| 88 | 100 | |
| 89 | 101 | public function block(string $name, Block $block = null) { |
| 90 | 102 | |
| 91 | - if (!isset($this->blocks[$name])) return ((null === $block) ? new Block() : $this); |
|
| 103 | + if (!isset($this->blocks[$name])) { |
|
| 104 | + return ((null === $block) ? new Block() : $this); |
|
| 105 | + } |
|
| 92 | 106 | |
| 93 | - if (null === $block) return $this->blocks[$name]; |
|
| 107 | + if (null === $block) { |
|
| 108 | + return $this->blocks[$name]; |
|
| 109 | + } |
|
| 94 | 110 | |
| 95 | 111 | $this->blocks[$name] = $block; |
| 96 | 112 | |
@@ -103,9 +119,13 @@ discard block |
||
| 103 | 119 | |
| 104 | 120 | public function loop(string $name, array $range = null) { |
| 105 | 121 | |
| 106 | - if (!isset($this->loops[$name])) return ((null === $range) ? new Loop() : $this); |
|
| 122 | + if (!isset($this->loops[$name])) { |
|
| 123 | + return ((null === $range) ? new Loop() : $this); |
|
| 124 | + } |
|
| 107 | 125 | |
| 108 | - if (null === $range) return $this->loops[$name]; |
|
| 126 | + if (null === $range) { |
|
| 127 | + return $this->loops[$name]; |
|
| 128 | + } |
|
| 109 | 129 | |
| 110 | 130 | $this->loops[$name]->range($range); |
| 111 | 131 | |
@@ -118,7 +138,9 @@ discard block |
||
| 118 | 138 | |
| 119 | 139 | public function set(string $name, string $value) { |
| 120 | 140 | |
| 121 | - if (isset($this->variables[$name])) $this->variables[$name] = $value; |
|
| 141 | + if (isset($this->variables[$name])) { |
|
| 142 | + $this->variables[$name] = $value; |
|
| 143 | + } |
|
| 122 | 144 | |
| 123 | 145 | return $this; |
| 124 | 146 | } |
@@ -127,7 +149,9 @@ discard block |
||
| 127 | 149 | |
| 128 | 150 | public function contents() { |
| 129 | 151 | |
| 130 | - if (!$this->enabled) return ''; |
|
| 152 | + if (!$this->enabled) { |
|
| 153 | + return ''; |
|
| 154 | + } |
|
| 131 | 155 | |
| 132 | 156 | $this->enabled = false; $insertions = []; |
| 133 | 157 | |
@@ -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,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,7 +28,9 @@ discard block |
||
| 23 | 28 | |
| 24 | 29 | $result = []; |
| 25 | 30 | |
| 26 | - foreach ($keys as $key) if (is_scalar($key)) $result[$key] = (isset($array[$key]) ? $array[$key] : false); |
|
| 31 | + foreach ($keys as $key) { |
|
| 32 | + if (is_scalar($key)) $result[$key] = (isset($array[$key]) ? $array[$key] : false); |
|
| 33 | + } |
|
| 27 | 34 | |
| 28 | 35 | # ------------------------ |
| 29 | 36 | |
@@ -36,7 +43,9 @@ discard block |
||
| 36 | 43 | |
| 37 | 44 | $result = []; |
| 38 | 45 | |
| 39 | - foreach ($array as $key => $value) $result[] = [$key_name => $key, $value_name => $value]; |
|
| 46 | + foreach ($array as $key => $value) { |
|
| 47 | + $result[] = [$key_name => $key, $value_name => $value]; |
|
| 48 | + } |
|
| 40 | 49 | |
| 41 | 50 | # ------------------------ |
| 42 | 51 | |
@@ -54,9 +63,15 @@ discard block |
||
| 54 | 63 | |
| 55 | 64 | $column = array_map($select_key, $array); |
| 56 | 65 | |
| 57 | - if (!$descending) asort($column); else arsort($column); |
|
| 66 | + if (!$descending) { |
|
| 67 | + asort($column); |
|
| 68 | + } else { |
|
| 69 | + arsort($column); |
|
| 70 | + } |
|
| 58 | 71 | |
| 59 | - $result = []; foreach (array_keys($column) as $key) $result[$key] = $array[$key]; |
|
| 72 | + $result = []; foreach (array_keys($column) as $key) { |
|
| 73 | + $result[$key] = $array[$key]; |
|
| 74 | + } |
|
| 60 | 75 | |
| 61 | 76 | # ------------------------ |
| 62 | 77 | |
@@ -10,7 +10,9 @@ |
||
| 10 | 10 | |
| 11 | 11 | protected static function init(string $file_name) { |
| 12 | 12 | |
| 13 | - if (is_array($list = Explorer::php($file_name))) static::$list = $list; |
|
| 13 | + if (is_array($list = Explorer::php($file_name))) { |
|
| 14 | + static::$list = $list; |
|
| 15 | + } |
|
| 14 | 16 | } |
| 15 | 17 | |
| 16 | 18 | # Check if item exists |