Prado\Data\SqlMap\DataMapper\TSqlMapTypeHandlerRegistry::createInstanceOf PHP Méthode

createInstanceOf() public méthode

Creates a new instance of a particular class (for PHP primative types, their corresponding default value for given type is used).
public createInstanceOf ( $type = '' ) : mixed
Résultat mixed default type value, if no type is specified null is returned.
    public function createInstanceOf($type = '')
    {
        if (strlen($type) > 0) {
            switch (strtolower($type)) {
                case 'string':
                    return '';
                case 'array':
                    return array();
                case 'float':
                case 'double':
                case 'decimal':
                    return 0.0;
                case 'integer':
                case 'int':
                    return 0;
                case 'bool':
                case 'boolean':
                    return false;
            }
            if (class_exists('Prado', false)) {
                return Prado::createComponent($type);
            } else {
                if (class_exists($type, false)) {
                    //NO auto loading
                    return new $type();
                } else {
                    throw new TSqlMapException('sqlmap_unable_to_find_class', $type);
                }
            }
        }
    }