/** * 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); } } }
/** * Returns the value to initially display with the input. * * @since 0.4.6 * * @return string */ protected function getValueToUse() { $value = $this->currentValue === false ? $this->param->getDefault() : $this->currentValue; if ($this->param->isList() && is_array($value)) { $value = implode($this->param->getDelimiter(), $value); } return $value; }