Factory class. Returns an object of the request
type.

@param string $type One of: Anonymous
Plain
CramMD5
DigestMD5
SCRAM-* (any mechanism of the SCRAM family)
Types are not case sensitive
773396
static function factory($type)
    {
        switch (strtolower($type)) {
            case 'anonymous':
                $filename  = dirname(__FILE__) . '/SASL/Anonymous.php';
                $classname = 'Auth_SASL_Anonymous';
                break;

            case 'login':
                $filename  = dirname(__FILE__) . '/SASL/Login.php';
                $classname = 'Auth_SASL_Login';
                break;

            case 'plain':
                $filename  = dirname(__FILE__) . '/SASL/Plain.php';
                $classname = 'Auth_SASL_Plain';
                break;

            case 'external':
                $filename  = dirname(__FILE__) . '/SASL/External.php';
                $classname = 'Auth_SASL_External';
                break;

            case 'crammd5':
                // $msg = 'Deprecated mechanism name. Use IANA-registered name: CRAM-MD5.';
                // trigger_error($msg, E_USER_DEPRECATED);
            case 'cram-md5':
                $filename  = dirname(__FILE__) . '/SASL/CramMD5.php';
                $classname = 'Auth_SASL_CramMD5';
                break;

            case 'digestmd5':
                // $msg = 'Deprecated mechanism name. Use IANA-registered name: DIGEST-MD5.';
                // trigger_error($msg, E_USER_DEPRECATED);
            case 'digest-md5':
                // $msg = 'DIGEST-MD5 is a deprecated SASL mechanism as per RFC-6331. Using it could be a security risk.';
                // trigger_error($msg, E_USER_NOTICE);
                $filename  = dirname(__FILE__) . '/SASL/DigestMD5.php';
                $classname = 'Auth_SASL_DigestMD5';
                break;

            default:
                $scram = '/^SCRAM-(.{1,9})$/i';
                $matches = [];
                if (preg_match($scram, $type, $matches))
                {
                    $hash = $matches[1];
                    $filename = dirname(__FILE__) .'/SASL/SCRAM.php';
                    $classname = 'Auth_SASL_SCRAM';
                    $parameter = $hash;
                    break;
                }
                throw new InvalidArgumentException('Invalid SASL mechanism type');
                break;
        }

        require_once $filename;
        if (isset($parameter)) {
            $obj = new $classname($parameter);
        } else {
            $obj = new $classname();
        }

        return $obj;
    }
1159930
public function build($type)
    {
        if (!isset($this->types[$type])) {
            throw new \Exception("Unknown request type.");
        }
        return new $this->types[$type]();
    }
782112
function factory($type)
	{
		include_once(ADODB_DIR."/drivers/adodb-$type.inc.php");
		$obj = NewADOConnection($type);
		if (!is_object($obj)) $obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1);
		return $obj;
	}
402558
protected function createDescriptorForType($type)
    {
        if (!$this->isArrayNotation($type)) {
            $className = $this->findClassNameForType($type);

            return $className ? new $className() : new UnknownTypeDescriptor($type);
        }

        $type       = $this->extractTypeFromArrayNotation($type);
        $className  = $this->findClassNameForType($type);
        $descriptor = $className ? new $className() : new UnknownTypeDescriptor($type);
        $descriptor = $this->convertToArrayDescriptor($descriptor);

        return $descriptor;
    }
1167186
public static function getPhpType($type)
    {
        switch ($type) {
            case self::TYPE_DOUBLE:
            case self::TYPE_FLOAT:
                return 'float';
            case self::TYPE_INT64:
            case self::TYPE_UINT64:
            case self::TYPE_INT32:
            case self::TYPE_FIXED64:
            case self::TYPE_FIXED32:
            case self::TYPE_UINT32:
            case self::TYPE_SFIXED32:
            case self::TYPE_SFIXED64:
            case self::TYPE_SINT32:
            case self::TYPE_SINT64:
                return 'int';
            case self::TYPE_BOOL:
                return 'bool';
            case self::TYPE_STRING:
                return 'string';
            case self::TYPE_BYTES:
                return '\Protobuf\Stream';
            default:
                return null;
        }
    }
818252
public function instantiate(string $type): object
    {
        if (!class_exists($type)) {
            throw new ClassNotFoundException;
        }

        $rClass = new ReflectionClass($type);
        $rConst = $rClass->getConstructor();
        if (is_null($rConst)) {
            return $rClass->newInstance();
        }

        return $rClass->newInstanceArgs($this->complete($rConst));
    }
1153977
private function getFromCache($type)
    {
        if (false === $this->hasCache()) {
            return null;
        }
        return $this->cache->loadMetadataFromCache($type);
    }
1305659
public function getNewType($type = null)
    {
        $className = $this->getTypeClass($type);
        /** @var GenericType $object */
        $object = new $className();
        $object->setManager($this);

        return $object;
    }
728146
public function get($type)
    {
        if (isset($this->definitions[$type])) {
            return $this->definitions[$type];
        }

        throw new UnregisteredDefinitionException(
            $type,
            UnregisteredDefinitionException::TARGET_MIME_TYPE
        );
    }
1122222
private static function getClass($type)
    {
        if (!\array_key_exists($type, self::$types)) {
            throw new \RuntimeException('invalid type');
        }

        return self::$types[$type];
    }
395535
static public function factory($object)
    {
        if (!isset($object->type)) {
            throw new ObjectException('The object has no type.');
        }

        $type = (string)$object->type;
        if (!isset(self::$types[$type])) {
            throw new NoSupportException(sprintf('The object type "%s" is unknown or invalid.', $type));
        }

        $class = '\\Omlex\\Object\\'.self::$types[$type];
        if (!class_exists($class)) {
            throw new ObjectException(sprintf('The object class "%s" is invalid or not found.', $class));
        }

        $instance = new $class($object);
        return $instance;
    }
30971
private function getTypeObject($type, $args)
    {
        /* @var AbstractType $object */
        if ($type instanceof AbstractType) {
            $object = $type;
        } else {
            $class = $this->getTypeClass($type);

            if (!\class_exists($class)) {
                $class = TextType::class;
            }

            $object = new $class($args, $this);
        }

        return $object;
    }
941494
public function unique($type = null)
  {
    if($type === null)
    {
      return self::_createRequest(null, 'unique', HttpVerb::GET);
    }
    else
    {
      $payload = new GetByEnumPayload();
      $payload->value = $type;
      return self::_createRequest($payload, 'unique', HttpVerb::POST);
    }
  }
1073689
public function type($type = null)
    {
        if (is_null($type)) {
            return $this->type;
        }

        $this->type = $type;

        return $this;
    }
116780
public function getTypeClass($type)
    {
        if (isset($this->types[$type])) {
            return $this->types[$type];
        }

        if (\class_exists($type)) {
            return $type;
        }

        return null;
    }
990259
public function factory($type)
    {
        if (!is_string($type)) {
            throw new \InvalidArgumentException('Invalid confirmation attributes value in confirmation factory');
        }
        if (!array_key_exists($type, $this->typeClassMap)) {
            throw new \InvalidArgumentException('Invalid confirmation attributes value type "'.$type.'"');
        }
        $className = __NAMESPACE__.'\\'.$this->typeClassMap[$type];

        return new $className();
    }
936729
private function getClass($type)
    {
        $collType = \SwaggerValidator\Common\CollectionType::getInstance();
        $class    = $collType->get($type);

        if (empty($class)) {
            $e = new \SwaggerValidator\Exception('Cannot retrieve the callable for this type : ' . $type);
            $e->setFile(__METHOD__);
            $e->setLine(__LINE__);
            throw $e;
        }

        return $class;
    }