Apply PSR-12 code style (#3886)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / html / metacode / converter / ColorMetacodeConverter.class.php
CommitLineData
60a35505 1<?php
a9229942 2
60a35505
AE
3namespace wcf\system\html\metacode\converter;
4
1d5f9363 5/**
607ff92e 6 * Converts color bbcode into `<span style="color: ...">`.
a9229942 7 *
4ccf5975 8 * @author Alexander Ebert
a9229942 9 * @copyright 2001-2019 WoltLab GmbH
4ccf5975
AE
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package WoltLabSuite\Core\System\Html\Metacode\Converter
12 * @since 3.0
1d5f9363 13 */
a9229942
TD
14class ColorMetacodeConverter extends AbstractMetacodeConverter
15{
16 /**
17 * @inheritDoc
18 */
19 public function convert(\DOMDocumentFragment $fragment, array $attributes)
20 {
21 $element = $fragment->ownerDocument->createElement('span');
22 $element->setAttribute('style', 'color: ' . $attributes[0]);
23 $element->appendChild($fragment);
24
25 return $element;
26 }
27
28 /**
29 * @inheritDoc
30 */
31 public function validateAttributes(array $attributes)
32 {
33 if (\count($attributes) !== 1) {
34 return false;
35 }
36
37 return true;
38 }
60a35505 39}