GetOptionKit\Option::_preprocessValue PHP Method

_preprocessValue() protected method

protected _preprocessValue ( $value )
    protected function _preprocessValue($value)
    {
        $val = $value;
        if ($isa = ucfirst($this->isa)) {
            $type = $this->getTypeClass();
            if ($type->test($value)) {
                $val = $type->parse($value);
            } else {
                throw new InvalidOptionValue("Invalid value for {$this->renderReadableSpec(false)}. Requires a type {$isa}.");
            }
        }
        // check pre-filter for option value
        if ($this->filter) {
            $val = call_user_func($this->filter, $val);
        }
        // check validValues
        if ($validValues = $this->getValidValues()) {
            if (!in_array($value, $validValues)) {
                throw new InvalidOptionValue('valid values are: ' . implode(', ', $validValues));
            }
        }
        return $val;
    }