@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * The base module implements the basic functionality for each module |
20 | 20 | */ |
21 | -class BaseModule implements BaseModuleInterface{ |
|
21 | +class BaseModule implements BaseModuleInterface { |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * The current bbcode tag |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @param \chillerlan\bbcode\BBTemp $bbtemp |
116 | 116 | */ |
117 | - public function __construct(BBTemp $bbtemp = null){ |
|
118 | - if($bbtemp instanceof BBTemp){ |
|
117 | + public function __construct(BBTemp $bbtemp = null) { |
|
118 | + if ($bbtemp instanceof BBTemp) { |
|
119 | 119 | $this->setBBTemp($bbtemp); |
120 | 120 | } |
121 | 121 | } |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return $this |
129 | 129 | */ |
130 | - public function setBBTemp(BBTemp $bbtemp){ |
|
131 | - foreach(['tag', 'attributes', 'content', 'parserOptions', 'languageInterface', 'depth'] as $var){ |
|
130 | + public function setBBTemp(BBTemp $bbtemp) { |
|
131 | + foreach (['tag', 'attributes', 'content', 'parserOptions', 'languageInterface', 'depth'] as $var) { |
|
132 | 132 | $this->{$var} = $bbtemp->{$var}; |
133 | 133 | } |
134 | 134 | |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return \chillerlan\bbcode\Modules\BaseModuleInfo |
142 | 142 | */ |
143 | - public function getInfo(){ |
|
143 | + public function getInfo() { |
|
144 | 144 | $info = new BaseModuleInfo; |
145 | 145 | |
146 | - foreach(['modules', 'eol_token'] as $option){ |
|
146 | + foreach (['modules', 'eol_token'] as $option) { |
|
147 | 147 | $info->{$option} = $this->{$option}; |
148 | 148 | } |
149 | 149 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @return \chillerlan\bbcode\Modules\Tagmap |
157 | 157 | * @see \chillerlan\bbcode\Modules\ModuleInterface |
158 | 158 | */ |
159 | - public function getTags(){ |
|
159 | + public function getTags() { |
|
160 | 160 | $tags = new Tagmap; |
161 | 161 | $tags->tags = $this->tags; |
162 | 162 | $tags->noparse_tags = $this->noparse_tags; |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @return $this |
172 | 172 | * @throws \chillerlan\bbcode\BBCodeException |
173 | 173 | */ |
174 | - public function checkTag(){ |
|
175 | - if(!$this->tag || !in_array($this->tag, $this->tags)){ |
|
174 | + public function checkTag() { |
|
175 | + if (!$this->tag || !in_array($this->tag, $this->tags)) { |
|
176 | 176 | throw new BBCodeException('tag ['.$this->tag.'] not supported.'); |
177 | 177 | } |
178 | 178 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @return string |
190 | 190 | */ |
191 | - public function eol($str, $eol = '', $count = null){ |
|
191 | + public function eol($str, $eol = '', $count = null) { |
|
192 | 192 | return str_replace($this->parserOptions->eol_placeholder, $eol, $str, $count); |
193 | 193 | } |
194 | 194 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return $this |
201 | 201 | */ |
202 | - public function clearEOL($eol = null){ |
|
202 | + public function clearEOL($eol = null) { |
|
203 | 203 | $eol = $eol ?: $this->eol_token; |
204 | 204 | $this->content = str_replace($this->parserOptions->eol_placeholder, $eol, $this->content); |
205 | 205 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return $this |
213 | 213 | */ |
214 | - public function clearPseudoClosingTags(){ |
|
214 | + public function clearPseudoClosingTags() { |
|
215 | 215 | $this->content = preg_replace('#\[/('.$this->parserOptions->singletags.')]#is', '', $this->content); |
216 | 216 | |
217 | 217 | return $this; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return mixed the attribute's value in case it exists, otherwise $default |
227 | 227 | */ |
228 | - public function getAttribute($name, $default = false){ |
|
228 | + public function getAttribute($name, $default = false) { |
|
229 | 229 | return isset($this->attributes[$name]) && !empty($this->attributes[$name]) ? $this->attributes[$name] : $default; |
230 | 230 | } |
231 | 231 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return mixed boolean if no $default is set, otherwise the attribute's value in case it exists and is whitelisted or $default |
240 | 240 | */ |
241 | - public function attributeIn($name, array $whitelist, $default = false){ |
|
241 | + public function attributeIn($name, array $whitelist, $default = false) { |
|
242 | 242 | return isset($this->attributes[$name]) && in_array($this->attributes[$name], $whitelist) |
243 | 243 | ? $default !== false ? $this->attributes[$name] : true |
244 | 244 | : $default; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return mixed boolean if no $default is set, otherwise the whitelist value to the given key in case it exists or $default |
255 | 255 | */ |
256 | - public function attributeKeyIn($name, array $whitelist, $default = false){ |
|
256 | + public function attributeKeyIn($name, array $whitelist, $default = false) { |
|
257 | 257 | return isset($this->attributes[$name]) && array_key_exists($this->attributes[$name], $whitelist) |
258 | 258 | ? $default !== false ? $whitelist[$this->attributes[$name]] : true |
259 | 259 | : $default; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * |
268 | 268 | * @return mixed boolean if no $default is set, otherwise the whitelisted tag or $default |
269 | 269 | */ |
270 | - public function tagIn(array $whitelist, $default = false){ |
|
270 | + public function tagIn(array $whitelist, $default = false) { |
|
271 | 271 | return in_array($this->tag, $whitelist) |
272 | 272 | ? $default !== false ? $this->tag : true |
273 | 273 | : $default; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @return string |
282 | 282 | * @codeCoverageIgnore |
283 | 283 | */ |
284 | - public function sanitize($content){ |
|
284 | + public function sanitize($content) { |
|
285 | 285 | return 'Implement sanitize() method!'; |
286 | 286 | } |
287 | 287 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * |
293 | 293 | * @see \chillerlan\bbcode\Modules\ModuleInterface::transform() |
294 | 294 | */ |
295 | - public function transform(){ |
|
295 | + public function transform() { |
|
296 | 296 | $this->checkTag(); |
297 | 297 | |
298 | 298 | /** @var $this \chillerlan\bbcode\Modules\ModuleInterface */ |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * |
307 | 307 | * @return mixed $this->attributes['__BBTAG__'] |
308 | 308 | */ |
309 | - protected function bbtag($default = false){ |
|
309 | + protected function bbtag($default = false) { |
|
310 | 310 | return $this->getAttribute($this->parserOptions->bbtag_placeholder, $default); |
311 | 311 | } |
312 | 312 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @return mixed |
320 | 320 | */ |
321 | - protected function bbtagIn(array $array, $default = false){ |
|
321 | + protected function bbtagIn(array $array, $default = false) { |
|
322 | 322 | return $this->attributeIn($this->parserOptions->bbtag_placeholder, $array, $default); |
323 | 323 | } |
324 | 324 | |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | * |
330 | 330 | * @return bool|string the url if valid, otherwise false |
331 | 331 | */ |
332 | - public function checkUrl($url){ |
|
333 | - if(filter_var($url, FILTER_VALIDATE_URL) === false){ |
|
332 | + public function checkUrl($url) { |
|
333 | + if (filter_var($url, FILTER_VALIDATE_URL) === false) { |
|
334 | 334 | return false; |
335 | 335 | } |
336 | 336 | // todo: check against whitelist? |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @return string |
348 | 348 | */ |
349 | - public function wrap($content, $wrapper){ |
|
349 | + public function wrap($content, $wrapper) { |
|
350 | 350 | return $wrapper.$content.$wrapper; |
351 | 351 | } |
352 | 352 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | * |
18 | 18 | * @see \chillerlan\bbcode\Modules\BaseModule::getInfo() |
19 | 19 | */ |
20 | -class BaseModuleInfo{ |
|
20 | +class BaseModuleInfo { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Holds an array of FQN strings to the current base module's children |
@@ -17,7 +17,7 @@ |
||
17 | 17 | /** |
18 | 18 | * Implements the basic functionality for each module |
19 | 19 | */ |
20 | -interface BaseModuleInterface{ |
|
20 | +interface BaseModuleInterface { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Sets self::$tag, self::$attributes, self::$content and self::$options |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * Transforms several code tags into HTML5 |
20 | 20 | */ |
21 | -class Code extends Html5BaseModule implements ModuleInterface{ |
|
21 | +class Code extends Html5BaseModule implements ModuleInterface { |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * An array of tags the module is able to process |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param \chillerlan\bbcode\BBTemp $bbtemp |
37 | 37 | */ |
38 | - public function __construct(BBTemp $bbtemp = null){ |
|
38 | + public function __construct(BBTemp $bbtemp = null) { |
|
39 | 39 | parent::__construct($bbtemp); |
40 | 40 | |
41 | 41 | // set self::$noparse_tags to self::$tags because none of these should be parsed |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @see \chillerlan\bbcode\Modules\BaseModuleInterface::transform() |
50 | 50 | * @internal |
51 | 51 | */ |
52 | - public function __transform(){ |
|
52 | + public function __transform() { |
|
53 | 53 | |
54 | - if(empty($this->content)){ |
|
54 | + if (empty($this->content)) { |
|
55 | 55 | return ''; |
56 | 56 | } |
57 | 57 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Transforms several container tags into HTML5 |
19 | 19 | */ |
20 | -class Containers extends Html5BaseModule implements ModuleInterface{ |
|
20 | +class Containers extends Html5BaseModule implements ModuleInterface { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * An array of tags the module is able to process |
@@ -35,16 +35,16 @@ discard block |
||
35 | 35 | * @see \chillerlan\bbcode\Modules\BaseModuleInterface::transform() |
36 | 36 | * @internal |
37 | 37 | */ |
38 | - public function __transform(){ |
|
38 | + public function __transform() { |
|
39 | 39 | |
40 | - if(empty($this->content)){ |
|
40 | + if (empty($this->content)) { |
|
41 | 41 | return ''; |
42 | 42 | } |
43 | 43 | |
44 | 44 | $tag = $this->tagIn(['p', 'div'], 'p'); |
45 | 45 | $align = $this->tagIn(self::TEXT_ALIGN, ''); |
46 | 46 | |
47 | - if(!$align){ |
|
47 | + if (!$align) { |
|
48 | 48 | $align = $this->attributeIn('align', self::TEXT_ALIGN, 'left'); |
49 | 49 | } |
50 | 50 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Transforms several expander tags into HTML5 |
19 | 19 | */ |
20 | -class Expanders extends Html5BaseModule implements ModuleInterface{ |
|
20 | +class Expanders extends Html5BaseModule implements ModuleInterface { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * An array of tags the module is able to process |
@@ -55,16 +55,16 @@ discard block |
||
55 | 55 | * @see \chillerlan\bbcode\Modules\BaseModuleInterface::transform() |
56 | 56 | * @internal |
57 | 57 | */ |
58 | - public function __transform(){ |
|
58 | + public function __transform() { |
|
59 | 59 | |
60 | - if(empty($this->content)){ |
|
60 | + if (empty($this->content)) { |
|
61 | 61 | return ''; |
62 | 62 | } |
63 | 63 | |
64 | 64 | call_user_func([$this, $this->tag]); |
65 | 65 | $id = $this->randomID(); |
66 | 66 | |
67 | - if(!$this->title){ |
|
67 | + if (!$this->title) { |
|
68 | 68 | $this->title = $this->header; |
69 | 69 | } |
70 | 70 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * Processes [expander] |
80 | 80 | */ |
81 | - protected function expander(){ |
|
81 | + protected function expander() { |
|
82 | 82 | $this->header = $this->languageInterface->expanderDisplayExpander(); |
83 | 83 | $this->display = $this->getAttribute('hide'); |
84 | 84 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * Processes [quote] |
88 | 88 | */ |
89 | - protected function quote(){ |
|
89 | + protected function quote() { |
|
90 | 90 | $name = $this->getAttribute('name'); |
91 | 91 | $url = $this->checkUrl($this->getAttribute('url')); |
92 | 92 | $header = $this->languageInterface->expanderDisplayQuote().($name ? ': '.$name : ''); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * Processes [spoiler] |
101 | 101 | */ |
102 | - protected function spoiler(){ |
|
102 | + protected function spoiler() { |
|
103 | 103 | $desc = $this->getAttribute('desc'); |
104 | 104 | |
105 | 105 | $this->header = $this->languageInterface->expanderDisplaySpoiler().($desc ? ': <span>'.$desc.'</span>' : ''); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * Processes [trigger] |
111 | 111 | */ |
112 | - protected function trigger(){ |
|
112 | + protected function trigger() { |
|
113 | 113 | $desc = $this->getAttribute('desc'); |
114 | 114 | |
115 | 115 | $this->header = $this->languageInterface->expanderDisplayTrigger().($desc ? ': <span>'.$desc.'</span>' : ''); |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * The base module implements the basic functionality for each module (HTML5) |
20 | 20 | */ |
21 | -class Html5BaseModule extends MarkupBaseModule implements BaseModuleInterface{ |
|
21 | +class Html5BaseModule extends MarkupBaseModule implements BaseModuleInterface { |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Holds an array of FQN strings to the current base module's children |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return string |
58 | 58 | */ |
59 | - public function sanitize($content){ |
|
59 | + public function sanitize($content) { |
|
60 | 60 | return htmlspecialchars($content, ENT_NOQUOTES | ENT_SUBSTITUTE | ENT_DISALLOWED | ENT_HTML5, 'UTF-8', false); |
61 | 61 | } |
62 | 62 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Transforms image tags into HTML5 |
19 | 19 | */ |
20 | -class Images extends Html5BaseModule implements ModuleInterface{ |
|
20 | +class Images extends Html5BaseModule implements ModuleInterface { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * An array of tags the module is able to process |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | * @see \chillerlan\bbcode\Modules\BaseModuleInterface::transform() |
35 | 35 | * @internal |
36 | 36 | */ |
37 | - public function __transform(){ |
|
37 | + public function __transform() { |
|
38 | 38 | |
39 | - if(!$url = $this->checkUrl($this->content)){ |
|
39 | + if (!$url = $this->checkUrl($this->content)) { |
|
40 | 40 | return ''; |
41 | 41 | } |
42 | 42 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Transforms link tags into HTML5 |
19 | 19 | */ |
20 | -class Links extends Html5BaseModule implements ModuleInterface{ |
|
20 | +class Links extends Html5BaseModule implements ModuleInterface { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * An array of tags the module is able to process |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | * @see \chillerlan\bbcode\Modules\BaseModuleInterface::transform() |
35 | 35 | * @internal |
36 | 36 | */ |
37 | - public function __transform(){ |
|
37 | + public function __transform() { |
|
38 | 38 | |
39 | - if(empty($this->content)){ |
|
39 | + if (empty($this->content)) { |
|
40 | 40 | return ''; |
41 | 41 | } |
42 | 42 | |
43 | - $url = $this->checkUrl($this->bbtag() ? : $this->content); |
|
43 | + $url = $this->checkUrl($this->bbtag() ?: $this->content); |
|
44 | 44 | $host = parse_url($url, PHP_URL_HOST); |
45 | 45 | $target = (!empty($host) && (isset($_SERVER['SERVER_NAME']) && $host === $_SERVER['SERVER_NAME'])) |
46 | 46 | || empty($host) ? 'self' : 'blank'; |