예제 #1
0
파일: Param.php 프로젝트: Tjorriemorrie/app
 /**
  * Sets the $value to a cleaned value of $originalValue.
  *
  * @since 0.5
  *
  * @param ValidatorOptions $options
  */
 protected function cleanValue(ValidatorOptions $options)
 {
     $this->value = $this->originalValue;
     if ($this->definition->isList()) {
         $this->value = explode($this->definition->getDelimiter(), $this->value);
     }
     $trim = $this->getDefinition()->trimDuringClean();
     if ($trim === true || is_null($trim) && $options->trimValues()) {
         if ($this->definition->isList()) {
             foreach ($this->value as &$element) {
                 if (is_string($element)) {
                     $element = trim($element);
                 }
             }
         } elseif (is_string($this->value)) {
             $this->value = trim($this->value);
         }
     }
     if ($options->lowercaseValues()) {
         if ($this->definition->isList()) {
             foreach ($this->value as &$element) {
                 if (is_string($element)) {
                     $element = strtolower($element);
                 }
             }
         } elseif (is_string($this->value)) {
             $this->value = strtolower($this->value);
         }
     }
 }