[TASK] Streamline phpdoc annotations in EXT:extbase
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Validation / Validator / StringLengthValidator.php
index c249773..f0b8f9b 100644 (file)
@@ -16,8 +16,6 @@ namespace TYPO3\CMS\Extbase\Validation\Validator;
 
 /**
  * Validator for string length.
- *
- * @api
  */
 class StringLengthValidator extends AbstractValidator
 {
@@ -35,9 +33,7 @@ class StringLengthValidator extends AbstractValidator
      * specified in the validation options.
      *
      * @param mixed $value The value that should be validated
-     * @return void
      * @throws \TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException
-     * @api
      */
     public function isValid($value)
     {
@@ -55,8 +51,7 @@ class StringLengthValidator extends AbstractValidator
             return;
         }
 
-        // @todo Use \TYPO3\CMS\Core\Charset\CharsetConverter::strlen() instead; How do we get the charset?
-        $stringLength = strlen($value);
+        $stringLength = mb_strlen($value, 'utf-8');
         $isValid = true;
         if ($stringLength < $this->options['minimum']) {
             $isValid = false;
@@ -75,7 +70,10 @@ class StringLengthValidator extends AbstractValidator
                             $this->options['minimum'],
                             $this->options['maximum']
                         ]
-                    ), 1428504122, [$this->options['minimum'], $this->options['maximum']]);
+                    ),
+                    1428504122,
+                    [$this->options['minimum'], $this->options['maximum']]
+                );
             } elseif ($this->options['minimum'] > 0) {
                 $this->addError(
                     $this->translateErrorMessage(
@@ -84,7 +82,10 @@ class StringLengthValidator extends AbstractValidator
                         [
                             $this->options['minimum']
                         ]
-                    ), 1238108068, [$this->options['minimum']]);
+                    ),
+                    1238108068,
+                    [$this->options['minimum']]
+                );
             } else {
                 $this->addError(
                     $this->translateErrorMessage(
@@ -93,7 +94,10 @@ class StringLengthValidator extends AbstractValidator
                         [
                             $this->options['maximum']
                         ]
-                    ), 1238108069, [$this->options['maximum']]);
+                    ),
+                    1238108069,
+                    [$this->options['maximum']]
+                );
             }
         }
     }