JBZoo\SimpleTypes\Type\Type::getValidValue PHP Method

getValidValue() public method

public getValidValue ( Type | string $value )
$value Type | string
    public function getValidValue($value)
    {
        if (is_object($value)) {
            $thisClass = strtolower(get_class($this));
            $valClass = strtolower(get_class($value));
            if ($thisClass !== $valClass) {
                throw new Exception($this->_type . ': No valid object type given: ' . $valClass);
            }
        } else {
            $className = get_class($this);
            $value = new $className($value, $this->_getConfig());
        }
        return $value;
    }