Factory method

@param $type Either a specific type, or null to get the default type.
@return \core\output\icon_system
495851
public final static function instance($type = null) {
        global $PAGE;

        if ($type == null) {
            if (!empty(self::$instance)) {
                return self::$instance;
            }
            $type = $PAGE->theme->get_icon_system();
            self::$instance = new $type();
            // Default one is a singleton.
            return self::$instance;
        } else {
            // Not a singleton.
            return new $type();
        }
    }
1006003
public static function icon($icon, $type = self::FONT_AWESOME)
    {
        $class = null;

        if ($type === self::FONT_AWESOME) {
            $class = 'fa fa-' . $icon;

        }
        else if ($type === self::FONT_BOOTSTRAP) {
            $class = 'glyphicon glyphicon-' . $icon;
        }
        else {
            $class = $icon;
        }

        return self::tag('i', '', $class, '');
    }
379074
public function make( $type )
    {
        $type = __NAMESPACE__ . "\\" . $type;
        if (class_exists( $type )) {
            /**
             * @var \Lti\Seo\Generators\Thing $object
             */
            $object = new $type( $this->helper );
            $result = $object->format();
            if (is_array( $result ) && ! empty( $result )) {
                return json_encode( array_merge( array( '@context' => 'http://schema.org' ), $result ) );
            }
        }

        return null;
    }
1257531
private static function getTyped($type)
    {
        if (!isset(static::$types[$type])) {
            static::$types[$type] = new self($type);
        }

        return static::$types[$type];
    }
540936
public function create($type = null)
    {
        app('antares.asset')->container('antares/foundation::application')->add('ckeditor', '/packages/ckeditor/ckeditor.js', ['webpack_forms_basic']);
        return $this->presenter->create($this->repository->makeModel()->getModel(), $type);
    }
338198
public static function create($type)
	{
		$generator = sprintf("Keygen\Generators\%sGenerator", ucfirst($type));

		if (class_exists($generator)) {
			$generator = new $generator;

			if ($generator instanceof Generator) {
				return $generator;
			}
		}

		throw new InvalidArgumentException('Cannot create unknown generator type.');
	}
740965
public function getType($type)
    {
        $type = ltrim($type, '\\');
        if (isset($this->classes[$type])) {
            return $this->classes[$type];
        } elseif (isset($this->interfaces[$type])) {
            return $this->interfaces[$type];
        } elseif (isset($this->traits[$type])) {
            return $this->traits[$type];
        }

        return null;
    }
1015183
public static function create($name, $type = NULL, $defaultValue = self::UNDEFINED, $modifiers = self::MODIFIER_PROTECTED) {
    if (isset($type)) {
      if ($type instanceof GClass) {
        $type = new ObjectType(new GClass($type->getFQN()));
      } elseif (!($type instanceof Type)) {
        $type = Type::create($type);
      }
    }
    
    return new static($name, $type, $defaultValue, $modifiers);
  }
280088
public function build($type)
    {
        if (!is_subclass_of($type, BaseSunat::class)) {
            throw new \Exception($type.' should be instance of '.BaseSunat::class);
        }

        /** @var $service BaseSunat */
        $service = new $type();
        $service->setClient($this->client);

        return $service;
    }
67843
public static function getInstance($type = 'default') {
		static $aclm = [];
		if (!isset($aclm[ $type ])) {
			$manager = new AclResourceManager();
			@fire('rbac\init' . ucfirst($type) . 'Manager', $manager);
			$aclm[ $type ] = $manager;
		}

		return $aclm[ $type ];
	}
1200629
public static function create($type = self::TYPE_SESSION)
    {
        $class_name = '\\cms\\login\\driver\\' . ucfirst($type) . 'Login';
        if (class_exists($class_name)) {
            try {
                return $class_name::instance();
            } catch (\Exception $e) {}
        }
    }
858956
public static function createWriter($type)
    {
        switch ($type) {
            case self::JSON:
                return new Impl\Json();
            case self::YAML:
                return new Impl\Yaml();
            case self::INI:
                return new Impl\Ini();
            case self::COLUMNS:
                return new Impl\Columns();
            case self::TABLE:
                return new Impl\ConsoleTable();
            case self::MARKDOWN:
                return new Impl\MarkdownTable();
            case self::DUMP:
                return new Impl\Dump();
        }

        throw new UnknownWriterTypeException("Sorry, writer type {$type} is not something I do");
    }
866771
public static function factory( $type = 'custom', $priority = 1000 ) {
		$class = self::verify_class_name( __CLASS__ . '_' . $type, 'Unexisting breadcrumb item type: "' . $type . '".' );

		$item = new $class( $priority );
		$item->set_type( $type );

		return $item;
	}
1040852
public function factory($type, $level = 0)
    {
        $result = null;

        if (!array_key_exists('type_extended_' . $type, $this->types)) {
            throw new InvalidTypeException;
        }

        /** @var $result ExtendedTypeInterface */
        $result = clone($this->types['type_extended_' . $type]);
        $result->setLevel($level);

        return $result;
    }
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));
    }
316371
public function getMachine(string $type)
	{
		foreach ($this->backends as $b => $backend) {
			$m = $backend->getMachine($this, $type);
			if ($m !== null) {
				return $m;
			}
		}
		return null;
	}
1355371
public function find($type)
    {
        if (!isset($this->instances[$type])) {
            trigger_error(sprintf("type '%s' is unregistered", $type), E_USER_WARNING);

            return $this->nullInstance;
        }

        $instance = $this->instances[$type];

        if ($instance instanceof TypeInterface) {
            return $instance;
        }

        if (is_string($instance) && class_exists($this->instances[$type])) {
            return $this->instances[$type] = new $instance();
        }

        trigger_error(sprintf("class '%s' does not exists", (string)$instance), E_USER_WARNING);
        unset($this->instances[$type]);

        return $this->nullInstance;
    }