@@ -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 |