/** * Sets the $value to a cleaned value of $originalValue. * * TODO: the per-parameter lowercaseing and trimming here needs some thought * * @since 1.0 * * @param Options $options */ protected function cleanValue(Options $options) { $this->value = $this->originalValue; $trim = $this->getDefinition()->trimDuringClean(); if ($trim === true || is_null($trim) && $options->trimValues()) { if (is_string($this->value)) { $this->value = trim($this->value); } } if ($this->definition->isList()) { $this->value = explode($this->definition->getDelimiter(), $this->value); if ($trim === true || is_null($trim) && $options->trimValues()) { foreach ($this->value as &$element) { if (is_string($element)) { $element = trim($element); } } } } $definitionOptions = $this->definition->getOptions(); if ($options->lowercaseValues() || array_key_exists('tolower', $definitionOptions) && $definitionOptions['tolower']) { 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); } } }