src/Chippyash/Type/TypeFactory.php
public static function create($type, $value, $extra = null)
    {
        switch (strtolower($type)) {
            case 'int':
            case 'integer':
                return self::createInt($value);
            case 'float':
            case 'double':
                return self::createFloat($value);
            case 'string':
                return self::createString($value);
            case 'bool':
            case 'boolean':
                return self::createBool($value);
            case 'digit':
                return self::createDigit($value);
            case 'natural':
                return self::createNatural($value);
            case 'whole':
                return self::createWhole($value);
            case 'complex':
                return self::createComplex($value, $extra);
            case 'rational':
                return self::createRational($value, $extra);
            default:
                throw new InvalidTypeException(strtolower($type));
        }
    }
public static function create($type, $value, $extra = null)
    {
        switch (strtolower($type)) {
            case 'int':
            case 'integer':
                return self::createInt($value);
            case 'float':
            case 'double':
                return self::createFloat($value);
            case 'string':
                return self::createString($value);
            case 'bool':
            case 'boolean':
                return self::createBool($value);
            case 'digit':
                return self::createDigit($value);
            case 'natural':
                return self::createNatural($value);
            case 'whole':
                return self::createWhole($value);
            case 'complex':
                return self::createComplex($value, $extra);
            case 'rational':
                return self::createRational($value, $extra);
            default:
                throw new InvalidTypeException(strtolower($type));
        }
    }
public static function create ( $ type , $ value , $ extra = null ) { switch ( strtolower ( $ type ) ) { case 'int' : case 'integer' : return self :: createInt ( $ value ) ; case 'float' : case 'double' : return self :: createFloat ( $ value ) ; case 'string' : return self :: createString ( $ value ) ; case 'bool' : case 'boolean' : return self :: createBool ( $ value ) ; case 'digit' : return self :: createDigit ( $ value ) ; case 'natural' : return self :: createNatural ( $ value ) ; case 'whole' : return self :: createWhole ( $ value ) ; case 'complex' : return self :: createComplex ( $ value , $ extra ) ; case 'rational' : return self :: createRational ( $ value , $ extra ) ; default : throw new InvalidTypeException ( strtolower ( $ type ) ) ; } }
Generic type factory

@param string $type
@param mixed $value
@param mixed $extra required for some types

@return \Chippyash\Type\AbstractType

@throws InvalidTypeException
Generic type factory