@@ -32,11 +32,15 @@ discard block |
||
32 | 32 | |
33 | 33 | $file_name = ($dir_name . $name . '/Config.json'); |
34 | 34 | |
35 | - if (false === ($config = Explorer::json($file_name))) continue; |
|
35 | + if (false === ($config = Explorer::json($file_name))) { |
|
36 | + continue; |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $config = Arr::select($config, self::$data); |
38 | 40 | |
39 | - if (!(self::valid($config['name']) && ($config['name'] === $name))) continue; |
|
41 | + if (!(self::valid($config['name']) && ($config['name'] === $name))) { |
|
42 | + continue; |
|
43 | + } |
|
40 | 44 | |
41 | 45 | $items[$name] = array_map('strval', $config); |
42 | 46 | } |
@@ -52,11 +56,19 @@ discard block |
||
52 | 56 | |
53 | 57 | $name = ''; $param = self::$param[self::$section]; |
54 | 58 | |
55 | - if (self::exists($name_cookie = Cookie::get($param))) $name = $name_cookie; |
|
59 | + if (self::exists($name_cookie = Cookie::get($param))) { |
|
60 | + $name = $name_cookie; |
|
61 | + } |
|
56 | 62 | |
57 | - if (self::exists($name_get = Request::get(self::$name))) $name = $name_get; |
|
63 | + if (self::exists($name_get = Request::get(self::$name))) { |
|
64 | + $name = $name_get; |
|
65 | + } |
|
58 | 66 | |
59 | - if ('' !== $name) Cookie::set($param, $name, self::$cookie_expires); else return false; |
|
67 | + if ('' !== $name) { |
|
68 | + Cookie::set($param, $name, self::$cookie_expires); |
|
69 | + } else { |
|
70 | + return false; |
|
71 | + } |
|
60 | 72 | |
61 | 73 | # ------------------------ |
62 | 74 | |
@@ -90,7 +102,9 @@ discard block |
||
90 | 102 | |
91 | 103 | $section = self::getSection($section); $dir_name = self::getDirName($section); |
92 | 104 | |
93 | - if (!Explorer::isDir($dir_name)) throw new Exception\General(self::$error_directory); |
|
105 | + if (!Explorer::isDir($dir_name)) { |
|
106 | + throw new Exception\General(self::$error_directory); |
|
107 | + } |
|
94 | 108 | |
95 | 109 | self::$section = $section; self::$dir_name = $dir_name; self::$items = self::getItems($dir_name); |
96 | 110 | |
@@ -98,11 +112,15 @@ discard block |
||
98 | 112 | |
99 | 113 | $primary = (self::exists(self::$default[$section]) ? self::$default[$section] : false); |
100 | 114 | |
101 | - if ($selectable && (false !== ($name = self::getUserDefined()))) $name_valid = true; |
|
102 | - |
|
103 | - else $name_valid = (self::exists($name = Settings::get($param)) || (false !== ($name = $primary))); |
|
115 | + if ($selectable && (false !== ($name = self::getUserDefined()))) { |
|
116 | + $name_valid = true; |
|
117 | + } else { |
|
118 | + $name_valid = (self::exists($name = Settings::get($param)) || (false !== ($name = $primary))); |
|
119 | + } |
|
104 | 120 | |
105 | - if (!($name_valid || (null !== ($name = key(self::$items))))) throw new Exception\General(self::$error_select); |
|
121 | + if (!($name_valid || (null !== ($name = key(self::$items))))) { |
|
122 | + throw new Exception\General(self::$error_select); |
|
123 | + } |
|
106 | 124 | |
107 | 125 | # ------------------------ |
108 | 126 | |
@@ -127,7 +145,9 @@ discard block |
||
127 | 145 | |
128 | 146 | public static function items(string $section = null) { |
129 | 147 | |
130 | - if (null === $section) return self::$items; |
|
148 | + if (null === $section) { |
|
149 | + return self::$items; |
|
150 | + } |
|
131 | 151 | |
132 | 152 | $section = self::getSection($section); $dir_name = self::getDirName($section); |
133 | 153 | |
@@ -152,7 +172,9 @@ discard block |
||
152 | 172 | |
153 | 173 | public static function path() { |
154 | 174 | |
155 | - if ('' === self::$active) return false; |
|
175 | + if ('' === self::$active) { |
|
176 | + return false; |
|
177 | + } |
|
156 | 178 | |
157 | 179 | return (self::$dir_name . self::$active . '/'); |
158 | 180 | } |
@@ -161,7 +183,9 @@ discard block |
||
161 | 183 | |
162 | 184 | public static function pathPrimary() { |
163 | 185 | |
164 | - if ('' === self::$primary) return false; |
|
186 | + if ('' === self::$primary) { |
|
187 | + return false; |
|
188 | + } |
|
165 | 189 | |
166 | 190 | return (self::$dir_name . self::$primary . '/'); |
167 | 191 | } |
@@ -170,9 +194,13 @@ discard block |
||
170 | 194 | |
171 | 195 | public static function data(string $name = null) { |
172 | 196 | |
173 | - if ('' === self::$active) return false; |
|
197 | + if ('' === self::$active) { |
|
198 | + return false; |
|
199 | + } |
|
174 | 200 | |
175 | - if (null === $name) return self::$items[self::$active]; |
|
201 | + if (null === $name) { |
|
202 | + return self::$items[self::$active]; |
|
203 | + } |
|
176 | 204 | |
177 | 205 | return (isset(self::$items[self::$active][$name]) ? self::$items[self::$active][$name] : false); |
178 | 206 | } |
@@ -37,7 +37,9 @@ discard block |
||
37 | 37 | |
38 | 38 | public static function __autoload() { |
39 | 39 | |
40 | - if (self::$loaded || empty($host = getenv('HTTP_HOST'))) return; |
|
40 | + if (self::$loaded || empty($host = getenv('HTTP_HOST'))) { |
|
41 | + return; |
|
42 | + } |
|
41 | 43 | |
42 | 44 | self::$settings['system_url'] = ((Request::isSecure() ? 'https://' : 'http://') . $host); |
43 | 45 | |
@@ -52,7 +54,9 @@ discard block |
||
52 | 54 | |
53 | 55 | self::$loaded = (false !== ($settings = Explorer::json($settings_file))); |
54 | 56 | |
55 | - if (self::$loaded) foreach ($settings as $name => $value) self::set($name, $value); |
|
57 | + if (self::$loaded) { |
|
58 | + foreach ($settings as $name => $value) self::set($name, $value); |
|
59 | + } |
|
56 | 60 | |
57 | 61 | # ------------------------ |
58 | 62 | |
@@ -65,9 +69,13 @@ discard block |
||
65 | 69 | |
66 | 70 | $settings_file = (DIR_SYSTEM_DATA . 'Settings.json'); |
67 | 71 | |
68 | - if (false === ($settings = json_encode(self::$settings, JSON_PRETTY_PRINT))) return false; |
|
72 | + if (false === ($settings = json_encode(self::$settings, JSON_PRETTY_PRINT))) { |
|
73 | + return false; |
|
74 | + } |
|
69 | 75 | |
70 | - if (false === Explorer::save($settings_file, $settings, true)) return false; |
|
76 | + if (false === Explorer::save($settings_file, $settings, true)) { |
|
77 | + return false; |
|
78 | + } |
|
71 | 79 | |
72 | 80 | # ------------------------ |
73 | 81 | |
@@ -85,34 +93,44 @@ discard block |
||
85 | 93 | |
86 | 94 | public static function set(string $name, $value) { |
87 | 95 | |
88 | - if (!isset(self::$settings[$name]) || !is_scalar($value)) return false; |
|
96 | + if (!isset(self::$settings[$name]) || !is_scalar($value)) { |
|
97 | + return false; |
|
98 | + } |
|
89 | 99 | |
90 | 100 | # Validate language |
91 | 101 | |
92 | 102 | if (($name === 'admin_language') || ($name === 'site_language')) { |
93 | 103 | |
94 | - if (false === ($value = Extend\Languages::validate($value))) return false; |
|
104 | + if (false === ($value = Extend\Languages::validate($value))) { |
|
105 | + return false; |
|
106 | + } |
|
95 | 107 | } |
96 | 108 | |
97 | 109 | # Validate template |
98 | 110 | |
99 | 111 | else if (($name === 'admin_template') || ($name === 'site_template')) { |
100 | 112 | |
101 | - if (false === ($value = Extend\Templates::validate($value))) return false; |
|
113 | + if (false === ($value = Extend\Templates::validate($value))) { |
|
114 | + return false; |
|
115 | + } |
|
102 | 116 | } |
103 | 117 | |
104 | 118 | # Validate site title |
105 | 119 | |
106 | 120 | else if ($name === 'site_title') { |
107 | 121 | |
108 | - if ('' === ($value = strval($value))) return false; |
|
122 | + if ('' === ($value = strval($value))) { |
|
123 | + return false; |
|
124 | + } |
|
109 | 125 | } |
110 | 126 | |
111 | 127 | # Validate site status |
112 | 128 | |
113 | 129 | else if ($name === 'site_status') { |
114 | 130 | |
115 | - if (false === ($value = Lister\Status::validate($value))) return false; |
|
131 | + if (false === ($value = Lister\Status::validate($value))) { |
|
132 | + return false; |
|
133 | + } |
|
116 | 134 | } |
117 | 135 | |
118 | 136 | # Validate site slogan/description/keywords |
@@ -126,21 +144,27 @@ discard block |
||
126 | 144 | |
127 | 145 | else if ($name === 'system_url') { |
128 | 146 | |
129 | - if (false === ($value = Validate::url($value))) return false; |
|
147 | + if (false === ($value = Validate::url($value))) { |
|
148 | + return false; |
|
149 | + } |
|
130 | 150 | } |
131 | 151 | |
132 | 152 | # Validate system email |
133 | 153 | |
134 | 154 | else if ($name === 'system_email') { |
135 | 155 | |
136 | - if (false === ($value = Validate::email($value))) return false; |
|
156 | + if (false === ($value = Validate::email($value))) { |
|
157 | + return false; |
|
158 | + } |
|
137 | 159 | } |
138 | 160 | |
139 | 161 | # Validate system timezone |
140 | 162 | |
141 | 163 | else if ($name === 'system_timezone') { |
142 | 164 | |
143 | - if (false === ($value = Timezone::validate($value))) return false; |
|
165 | + if (false === ($value = Timezone::validate($value))) { |
|
166 | + return false; |
|
167 | + } |
|
144 | 168 | } |
145 | 169 | |
146 | 170 | # Validate users registration |
@@ -163,7 +187,9 @@ discard block |
||
163 | 187 | |
164 | 188 | public static function get(string $name = null) { |
165 | 189 | |
166 | - if (null === $name) return self::$settings; |
|
190 | + if (null === $name) { |
|
191 | + return self::$settings; |
|
192 | + } |
|
167 | 193 | |
168 | 194 | return (isset(self::$settings[$name]) ? self::$settings[$name] : null); |
169 | 195 | } |
@@ -14,7 +14,9 @@ discard block |
||
14 | 14 | |
15 | 15 | $parts = preg_split('/\//', $string, 0, PREG_SPLIT_NO_EMPTY); |
16 | 16 | |
17 | - foreach ($parts as $name) if (!preg_match($regex, $name)) return false; |
|
17 | + foreach ($parts as $name) { |
|
18 | + if (!preg_match($regex, $name)) return false; |
|
19 | + } |
|
18 | 20 | |
19 | 21 | # ------------------------ |
20 | 22 | |
@@ -27,9 +29,13 @@ discard block |
||
27 | 29 | |
28 | 30 | $data = Arr::select($item, ['path', 'handler']); |
29 | 31 | |
30 | - if (false === ($path = $this->parseString($data['path'], REGEX_MAP_ITEM_PATH))) return; |
|
32 | + if (false === ($path = $this->parseString($data['path'], REGEX_MAP_ITEM_PATH))) { |
|
33 | + return; |
|
34 | + } |
|
31 | 35 | |
32 | - if (false === ($handler = $this->parseString($data['handler'], REGEX_MAP_ITEM_HANDLER))) return; |
|
36 | + if (false === ($handler = $this->parseString($data['handler'], REGEX_MAP_ITEM_HANDLER))) { |
|
37 | + return; |
|
38 | + } |
|
33 | 39 | |
34 | 40 | $this->map[] = ['path' => $path, 'handler' => implode('\\', $handler)]; |
35 | 41 | } |
@@ -40,16 +46,22 @@ discard block |
||
40 | 46 | |
41 | 47 | $file_name = (DIR_SYSTEM_DATA . 'Map.json'); |
42 | 48 | |
43 | - if (false === ($map = Explorer::json($file_name))) return; |
|
49 | + if (false === ($map = Explorer::json($file_name))) { |
|
50 | + return; |
|
51 | + } |
|
44 | 52 | |
45 | - foreach ($map as $item) if (is_array($item)) $this->parseItem($item); |
|
53 | + foreach ($map as $item) { |
|
54 | + if (is_array($item)) $this->parseItem($item); |
|
55 | + } |
|
46 | 56 | } |
47 | 57 | |
48 | 58 | # Get handler by url |
49 | 59 | |
50 | 60 | public function handler(Url $url) { |
51 | 61 | |
52 | - foreach ($this->map as $item) if ($item['path'] === $url->path()) return $item['handler']; |
|
62 | + foreach ($this->map as $item) { |
|
63 | + if ($item['path'] === $url->path()) return $item['handler']; |
|
64 | + } |
|
53 | 65 | |
54 | 66 | return false; |
55 | 67 | } |
@@ -18,12 +18,16 @@ discard block |
||
18 | 18 | |
19 | 19 | foreach (array_keys($this->database) as $key) { |
20 | 20 | |
21 | - if (is_scalar($value = Arr::get($data, ['database', $key]))) $this->database[$key] = strval($value); |
|
21 | + if (is_scalar($value = Arr::get($data, ['database', $key]))) { |
|
22 | + $this->database[$key] = strval($value); |
|
23 | + } |
|
22 | 24 | } |
23 | 25 | |
24 | 26 | # Parse installation details |
25 | 27 | |
26 | - if (is_numeric($time = Arr::get($data, ['time']))) $this->time = intval($time); |
|
28 | + if (is_numeric($time = Arr::get($data, ['time']))) { |
|
29 | + $this->time = intval($time); |
|
30 | + } |
|
27 | 31 | } |
28 | 32 | |
29 | 33 | # Constructor |
@@ -32,7 +36,9 @@ discard block |
||
32 | 36 | |
33 | 37 | $system_file = (DIR_SYSTEM_DATA . 'System.json'); |
34 | 38 | |
35 | - if (false !== ($data = Explorer::json($system_file))) $this->parse($data); |
|
39 | + if (false !== ($data = Explorer::json($system_file))) { |
|
40 | + $this->parse($data); |
|
41 | + } |
|
36 | 42 | } |
37 | 43 | } |
38 | 44 | } |
@@ -12,9 +12,13 @@ discard block |
||
12 | 12 | |
13 | 13 | while (false !== ($name = readdir($handler))) { |
14 | 14 | |
15 | - if (($name === '.') || ($name === '..')) continue; |
|
15 | + if (($name === '.') || ($name === '..')) { |
|
16 | + continue; |
|
17 | + } |
|
16 | 18 | |
17 | - if ($dirs ? @is_dir($dir_name . $name) : @is_file($dir_name . $name)) yield $name; |
|
19 | + if ($dirs ? @is_dir($dir_name . $name) : @is_file($dir_name . $name)) { |
|
20 | + yield $name; |
|
21 | + } |
|
18 | 22 | } |
19 | 23 | |
20 | 24 | closedir($handler); |
@@ -25,7 +29,9 @@ discard block |
||
25 | 29 | |
26 | 30 | private static function getInfo(string $file_name, int $param, bool $check_exists = true) { |
27 | 31 | |
28 | - if ($check_exists && !self::isFile($file_name)) return false; |
|
32 | + if ($check_exists && !self::isFile($file_name)) { |
|
33 | + return false; |
|
34 | + } |
|
29 | 35 | |
30 | 36 | return pathinfo($file_name, $param); |
31 | 37 | } |
@@ -68,9 +74,11 @@ discard block |
||
68 | 74 | |
69 | 75 | $name = ($dir_name . '/' . $name); |
70 | 76 | |
71 | - if (@is_file($name)) self::removeFile($name); |
|
72 | - |
|
73 | - else if (@is_dir($name)) self::removeDir($name, true); |
|
77 | + if (@is_file($name)) { |
|
78 | + self::removeFile($name); |
|
79 | + } else if (@is_dir($name)) { |
|
80 | + self::removeDir($name, true); |
|
81 | + } |
|
74 | 82 | } |
75 | 83 | } |
76 | 84 | |
@@ -146,7 +154,9 @@ discard block |
||
146 | 154 | |
147 | 155 | public static function json(string $file_name) { |
148 | 156 | |
149 | - if ((strtolower(self::extension($file_name)) !== 'json')) return false; |
|
157 | + if ((strtolower(self::extension($file_name)) !== 'json')) { |
|
158 | + return false; |
|
159 | + } |
|
150 | 160 | |
151 | 161 | return (json_decode(@file_get_contents($file_name), true) ?? false); |
152 | 162 | } |
@@ -155,7 +165,9 @@ discard block |
||
155 | 165 | |
156 | 166 | public static function php(string $file_name) { |
157 | 167 | |
158 | - if ((strtolower(self::extension($file_name)) !== 'php')) return false; |
|
168 | + if ((strtolower(self::extension($file_name)) !== 'php')) { |
|
169 | + return false; |
|
170 | + } |
|
159 | 171 | |
160 | 172 | return include $file_name; |
161 | 173 | } |
@@ -164,7 +176,9 @@ discard block |
||
164 | 176 | |
165 | 177 | public static function xml(string $file_name) { |
166 | 178 | |
167 | - if ((strtolower(self::extension($file_name)) !== 'xml')) return false; |
|
179 | + if ((strtolower(self::extension($file_name)) !== 'xml')) { |
|
180 | + return false; |
|
181 | + } |
|
168 | 182 | |
169 | 183 | return @simplexml_load_file($file_name); |
170 | 184 | } |
@@ -173,7 +187,11 @@ discard block |
||
173 | 187 | |
174 | 188 | public static function save(string $file_name, string $contents, bool $force = false) { |
175 | 189 | |
176 | - if (self::isFile($file_name)) if (!$force) return false; else if (!@unlink($file_name)) return false; |
|
190 | + if (self::isFile($file_name)) { |
|
191 | + if (!$force) return false; |
|
192 | + } else if (!@unlink($file_name)) { |
|
193 | + return false; |
|
194 | + } |
|
177 | 195 | |
178 | 196 | return @file_put_contents($file_name, $contents); |
179 | 197 | } |
@@ -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 | $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 | - $result = []; foreach (array_keys($column) as $key) $result[$key] = $array[$key]; |
|
75 | + $result = []; foreach (array_keys($column) as $key) { |
|
76 | + $result[$key] = $array[$key]; |
|
77 | + } |
|
63 | 78 | |
64 | 79 | # ------------------------ |
65 | 80 |
@@ -14,7 +14,9 @@ discard block |
||
14 | 14 | |
15 | 15 | $urlset = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />'; |
16 | 16 | |
17 | - if (false !== ($xml = XML::create($urlset))) $this->xml = $xml; |
|
17 | + if (false !== ($xml = XML::create($urlset))) { |
|
18 | + $this->xml = $xml; |
|
19 | + } |
|
18 | 20 | } |
19 | 21 | |
20 | 22 | # Load sitemap |
@@ -25,9 +27,13 @@ discard block |
||
25 | 27 | |
26 | 28 | $modified = Explorer::modified($file_name); |
27 | 29 | |
28 | - if ((false === $modified) || ($modified <= $time)) return false; |
|
30 | + if ((false === $modified) || ($modified <= $time)) { |
|
31 | + return false; |
|
32 | + } |
|
29 | 33 | |
30 | - if (false === ($xml = Explorer::xml($file_name))) return false; |
|
34 | + if (false === ($xml = Explorer::xml($file_name))) { |
|
35 | + return false; |
|
36 | + } |
|
31 | 37 | |
32 | 38 | $this->xml = $xml; $this->loaded = true; |
33 | 39 | |
@@ -40,11 +46,15 @@ discard block |
||
40 | 46 | |
41 | 47 | public function save() { |
42 | 48 | |
43 | - if ((null === $this->xml) || $this->loaded) return false; |
|
49 | + if ((null === $this->xml) || $this->loaded) { |
|
50 | + return false; |
|
51 | + } |
|
44 | 52 | |
45 | 53 | $file_name = (DIR_SYSTEM_DATA . 'Sitemap.xml'); |
46 | 54 | |
47 | - if (false === Explorer::save($file_name, XML::string($this->xml), true)) return false; |
|
55 | + if (false === Explorer::save($file_name, XML::string($this->xml), true)) { |
|
56 | + return false; |
|
57 | + } |
|
48 | 58 | |
49 | 59 | # ------------------------ |
50 | 60 | |
@@ -55,9 +65,13 @@ discard block |
||
55 | 65 | |
56 | 66 | public function add(string $loc, string $lastmod = null, string $changefreq = null, float $priority = null) { |
57 | 67 | |
58 | - if ((null === $this->xml) || $this->loaded) return false; |
|
68 | + if ((null === $this->xml) || $this->loaded) { |
|
69 | + return false; |
|
70 | + } |
|
59 | 71 | |
60 | - if (false === ($loc = Validate::url($loc))) return false; |
|
72 | + if (false === ($loc = Validate::url($loc))) { |
|
73 | + return false; |
|
74 | + } |
|
61 | 75 | |
62 | 76 | # Create url object |
63 | 77 | |
@@ -79,7 +93,9 @@ discard block |
||
79 | 93 | |
80 | 94 | # Set priority |
81 | 95 | |
82 | - if (null !== $priority) $url->addChild('priority', Number::formatFloat($priority, 0, 1, 1)); |
|
96 | + if (null !== $priority) { |
|
97 | + $url->addChild('priority', Number::formatFloat($priority, 0, 1, 1)); |
|
98 | + } |
|
83 | 99 | |
84 | 100 | # ------------------------ |
85 | 101 |
@@ -12,11 +12,19 @@ discard block |
||
12 | 12 | |
13 | 13 | private function allocateColor(array $color = null) { |
14 | 14 | |
15 | - if (null === $this->image) return false; |
|
15 | + if (null === $this->image) { |
|
16 | + return false; |
|
17 | + } |
|
16 | 18 | |
17 | - if (null === $color) $color = [0, 0, 0]; else if (count($color) !== 3) return false; |
|
19 | + if (null === $color) { |
|
20 | + $color = [0, 0, 0]; |
|
21 | + } else if (count($color) !== 3) { |
|
22 | + return false; |
|
23 | + } |
|
18 | 24 | |
19 | - foreach (array_values($color) as $key => $value) $color[$key] = Number::format($value, 0, 255); |
|
25 | + foreach (array_values($color) as $key => $value) { |
|
26 | + $color[$key] = Number::format($value, 0, 255); |
|
27 | + } |
|
20 | 28 | |
21 | 29 | # ------------------------ |
22 | 30 | |
@@ -27,7 +35,9 @@ discard block |
||
27 | 35 | |
28 | 36 | public function __construct(int $width, int $height, array $bg_color = null) { |
29 | 37 | |
30 | - if (false === ($image = imagecreatetruecolor($width, $height))) return; |
|
38 | + if (false === ($image = imagecreatetruecolor($width, $height))) { |
|
39 | + return; |
|
40 | + } |
|
31 | 41 | |
32 | 42 | $this->image = $image; $this->width = $width; $this->height = $height; |
33 | 43 | |
@@ -41,11 +51,17 @@ discard block |
||
41 | 51 | |
42 | 52 | public function text(string $font, int $size, int $indent, int $step, string $text, array $color = null) { |
43 | 53 | |
44 | - if (null === $this->image) return false; |
|
54 | + if (null === $this->image) { |
|
55 | + return false; |
|
56 | + } |
|
45 | 57 | |
46 | - if (!Explorer::isFile($font)) return false; |
|
58 | + if (!Explorer::isFile($font)) { |
|
59 | + return false; |
|
60 | + } |
|
47 | 61 | |
48 | - if (false === ($color = $this->allocateColor($color))) return false; |
|
62 | + if (false === ($color = $this->allocateColor($color))) { |
|
63 | + return false; |
|
64 | + } |
|
49 | 65 | |
50 | 66 | $base = (floor(($this->height - $size) / 2) + $size); |
51 | 67 | |
@@ -65,13 +81,22 @@ discard block |
||
65 | 81 | |
66 | 82 | public function noise(int $rate, array $color = null) { |
67 | 83 | |
68 | - if (null === $this->image) return false; |
|
84 | + if (null === $this->image) { |
|
85 | + return false; |
|
86 | + } |
|
69 | 87 | |
70 | - if (false === ($color = $this->allocateColor($color))) return false; |
|
88 | + if (false === ($color = $this->allocateColor($color))) { |
|
89 | + return false; |
|
90 | + } |
|
71 | 91 | |
72 | - for ($x = 0; $x < $this->width; $x++) for ($y = 0; $y < $this->height; $y++) { |
|
92 | + for ($x = 0; $x < $this->width; $x++) { |
|
93 | + for ($y = 0; |
|
94 | + } |
|
95 | + $y < $this->height; $y++) { |
|
73 | 96 | |
74 | - if (random_int(1, $rate) === 1) imagesetpixel($this->image, $x, $y, $color); |
|
97 | + if (random_int(1, $rate) === 1) { |
|
98 | + imagesetpixel($this->image, $x, $y, $color); |
|
99 | + } |
|
75 | 100 | } |
76 | 101 | |
77 | 102 | # ------------------------ |
@@ -83,9 +108,13 @@ discard block |
||
83 | 108 | |
84 | 109 | public function lines(int $count, array $color = null) { |
85 | 110 | |
86 | - if (null === $this->image) return false; |
|
111 | + if (null === $this->image) { |
|
112 | + return false; |
|
113 | + } |
|
87 | 114 | |
88 | - if (false === ($color = $this->allocateColor($color))) return false; |
|
115 | + if (false === ($color = $this->allocateColor($color))) { |
|
116 | + return false; |
|
117 | + } |
|
89 | 118 | |
90 | 119 | for ($i = 0; $i < $count; $i++) { |
91 | 120 |
@@ -17,7 +17,9 @@ |
||
17 | 17 | |
18 | 18 | public static function string(SimpleXMLElement $xml) { |
19 | 19 | |
20 | - if (false === ($xml = dom_import_simplexml($xml))) return ''; |
|
20 | + if (false === ($xml = dom_import_simplexml($xml))) { |
|
21 | + return ''; |
|
22 | + } |
|
21 | 23 | |
22 | 24 | $dom = $xml->ownerDocument; $dom->formatOutput = true; |
23 | 25 |