Apply PSR-12 code style (#3886)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / form / builder / field / bbcode / BBCodeAttributesFormField.class.php
index b0e12d4c4235f5c7a5cf1ddbec6cf6edabeb554b..44d3b96c7916af427c78bcadfb9756d999167472 100644 (file)
@@ -1,5 +1,7 @@
 <?php
+
 namespace wcf\system\form\builder\field\bbcode;
+
 use wcf\system\form\builder\field\AbstractFormField;
 use wcf\system\form\builder\field\TDefaultIdFormField;
 use wcf\system\form\builder\field\validation\FormFieldValidationError;
@@ -7,81 +9,87 @@ use wcf\system\Regex;
 
 /**
  * Implementation of a form field for the attributes of a form field.
- * 
- * @author     Matthias Schmidt
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\System\Form\Builder\Field\BBCode
- * @since      5.2
+ *
+ * @author  Matthias Schmidt
+ * @copyright   2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Form\Builder\Field\BBCode
+ * @since   5.2
  */
-class BBCodeAttributesFormField extends AbstractFormField {
-       use TDefaultIdFormField;
-       
-       /**
-        * @inheritDoc
-        */
-       protected $templateName = '__bbcodeAttributesFormField';
-       
-       /**
-        * @inheritDoc
-        */
-       protected $value = [];
-       
-       /**
-        * @inheritDoc
-        */
-       protected static function getDefaultId() {
-               return 'attributes';
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       public function readValue() {
-               if ($this->getDocument()->hasRequestData($this->getPrefixedId()) && is_array($this->getDocument()->getRequestData($this->getPrefixedId()))) {
-                       $this->value = $this->getDocument()->getRequestData($this->getPrefixedId());
-               }
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       public function validate() {
-               foreach ($this->getValue() as $attributeNumber => $attributeData) {
-                       if (!empty($attributeData['attributeHtml']) && mb_strlen($attributeData['attributeHtml']) > 255) {
-                               $this->addValidationError(
-                                       new FormFieldValidationError(
-                                               $this->getPrefixedId() . '_attributeHtml_' . $attributeNumber,
-                                               'wcf.form.field.text.error.maximumLength',
-                                               [
-                                                       'length' => mb_strlen($attributeData['attributeHtml']),
-                                                       'maximumLength' => 255
-                                               ]
-                                       )
-                               );
-                       }
-                       if (!empty($attributeData['validationPattern'])) {
-                               if (mb_strlen($attributeData['validationPattern']) > 255) {
-                                       $this->addValidationError(
-                                               new FormFieldValidationError(
-                                                       $this->getPrefixedId() . '_validationPattern_' . $attributeNumber,
-                                                       'wcf.form.field.text.error.maximumLength',
-                                                       [
-                                                               'length' => mb_strlen($attributeData['validationPattern']),
-                                                               'maximumLength' => 255
-                                                       ]
-                                               )
-                                       );
-                               }
-                               else if (!Regex::compile($attributeData['validationPattern'])->isValid()) {
-                                       $this->addValidationError(
-                                               new FormFieldValidationError(
-                                                       $this->getPrefixedId() . '_validationPattern_' . $attributeNumber,
-                                                       'wcf.acp.bbcode.attribute.validationPattern.error.invalid'
-                                               )
-                                       );
-                               }
-                       }
-               }
-       }
+class BBCodeAttributesFormField extends AbstractFormField
+{
+    use TDefaultIdFormField;
+
+    /**
+     * @inheritDoc
+     */
+    protected $templateName = '__bbcodeAttributesFormField';
+
+    /**
+     * @inheritDoc
+     */
+    protected $value = [];
+
+    /**
+     * @inheritDoc
+     */
+    protected static function getDefaultId()
+    {
+        return 'attributes';
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function readValue()
+    {
+        if (
+            $this->getDocument()->hasRequestData($this->getPrefixedId())
+            && \is_array($this->getDocument()->getRequestData($this->getPrefixedId()))
+        ) {
+            $this->value = $this->getDocument()->getRequestData($this->getPrefixedId());
+        }
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function validate()
+    {
+        foreach ($this->getValue() as $attributeNumber => $attributeData) {
+            if (!empty($attributeData['attributeHtml']) && \mb_strlen($attributeData['attributeHtml']) > 255) {
+                $this->addValidationError(
+                    new FormFieldValidationError(
+                        $this->getPrefixedId() . '_attributeHtml_' . $attributeNumber,
+                        'wcf.form.field.text.error.maximumLength',
+                        [
+                            'length' => \mb_strlen($attributeData['attributeHtml']),
+                            'maximumLength' => 255,
+                        ]
+                    )
+                );
+            }
+            if (!empty($attributeData['validationPattern'])) {
+                if (\mb_strlen($attributeData['validationPattern']) > 255) {
+                    $this->addValidationError(
+                        new FormFieldValidationError(
+                            $this->getPrefixedId() . '_validationPattern_' . $attributeNumber,
+                            'wcf.form.field.text.error.maximumLength',
+                            [
+                                'length' => \mb_strlen($attributeData['validationPattern']),
+                                'maximumLength' => 255,
+                            ]
+                        )
+                    );
+                } elseif (!Regex::compile($attributeData['validationPattern'])->isValid()) {
+                    $this->addValidationError(
+                        new FormFieldValidationError(
+                            $this->getPrefixedId() . '_validationPattern_' . $attributeNumber,
+                            'wcf.acp.bbcode.attribute.validationPattern.error.invalid'
+                        )
+                    );
+                }
+            }
+        }
+    }
 }