@brief if requested API is already instantiated, grabs instance from an array, otherwise autoloads an instance of the API
@param string $class
@param integer|null $object

@return mixed
545121
public function getApi($class, $object = NULL)
    {
        $absoluteClass = "\\OntraportAPI\\" . $class;

        // For custom objects
        if ($object)
        {
            // Generate a unique name so that wrong object id is not stored with instantiated class
            $class = $class . "." . $object;
            if (!array_key_exists($class, $this->_apiInstances))
            {
                $this->_apiInstances[$class] = new $absoluteClass($this, $object);
            }
        }

        else
        {
            if (!array_key_exists($class, $this->_apiInstances))
            {
                $this->_apiInstances[$class] = new $absoluteClass($this);
            }
        }

        return $this->_apiInstances[$class];
    }
414550
public function fetchAllObj(string $class = null): array
    {
        if (!$this->wasExecuted()) {
            $this->exec();
        }

        if ($class === null) {
            return $this->getAdapter()->getStatement()->fetchAll(PDO::FETCH_OBJ);
        } else {
            $objects = [];
            foreach ($this->fetchAll() as $record) {
                $objects[] = new $class($record);
            }

            return $objects;
        }
    }
1084969
public function get($class = null)
        {
            $class = $this->getClass($class);

            if (Arrays::exists($class, $this->reflections)) {
                return $this->reflections[$class];
            }

            throw new Exception("Class not found: $class");
        }
135148
public function get($class, ...$args)
    {
        $poolName = trim($class, '\\');

        if (!$poolName) {
            return null;
        }

        $pool     = $this->map[$poolName] ?? null;
        if ($pool == null) {
            $pool = $this->applyNewPool($poolName);
        }

        if ($pool->count()) {
            $obj = $pool->shift();
            $obj->__isConstruct = false;
            return $obj;
        } else {
            $reflector         = new \ReflectionClass($poolName);
            $obj               = $reflector->newInstanceWithoutConstructor();
            $obj->__useCount   = 0;
            $obj->__genTime    = time();
            $obj->__isConstruct = false;
            $obj->__DSLevel    = Macro::DS_PUBLIC;
            unset($reflector);
            return $obj;
        }
    }
941148
public function getParameterClassObject($object, $method)
    {
        $reflectionClass = new \ReflectionClass(get_class($object));
        $parameters = $reflectionClass->getMethod($method)->getParameters();

        if ($parameters && isset($parameters[0])) {
            $refClass = $parameters[0]->getClass();

            if ($refClass) {
                $class = $refClass->getName();

                return new $class();
            }
        }
    }
721344
final public static function getInstance($calledClass = null)
    {
        $calledClass = $calledClass ?: get_called_class();

        if (!isset(self::$instances[ $calledClass ])) {
            self::$instances[ $calledClass ] = new $calledClass();
        }

        return self::$instances[ $calledClass ];
    }
1349128
static function instance($class = null) {
        if (!$class) {
            $class = get_called_class();
        }
        if (!is_a($class, ValidateBuilder::class, true)) {
            throw new \Exception($class . ' is not a subclass of ' . ValidateBuilder::class);
        }
        if (!isset(self::$instances[$class])) {
            self::$instances[$class] = new $class;
        }

        return self::$instances[$class];
    }
729920
public function getResponseObject(string $class, string $json)
    {
        $object = $this->deserialize($class, $json);
        $this->assertValid($object, ValidationException::RESPONSE);

        return $object;
    }
960968
public static function from($object): self
    {
        if ($object instanceof self) {
            return $object;
        }

        if (\is_object($object)) {
            $object = \get_class($object);
        }

        if (! \is_string($object)) {
            throw new InvalidArgumentException('Cannot create a type from '.\gettype($object));
        }

        return new self($object);
    }
444756
public static function loadClass($class)
    {
        if (isset(self::$_classMap[$class]))
            return (bool)require sprintf('%s/%s', self::ROOT_DIR, self::$_classMap[$class]);
        return null;
    }
1141870
public static function get($class)
    {
        $key = strtolower($class);

        if (isset(static::$instances[$key])) {
            return static::$instances[$key];
        }

        static::override($class);

        if (!class_exists($class)) {
            throw new ReflectionException("Class $class does not exist");
        }

        $instance = static::getInstance($class);
        static::register($class, $instance);
        return $instance;
    }
852419
public function get(string $class, array $parameters = [], bool $reuseInstance = true): object
	{
		$class = $this->resolveAlias($class);

		// If a singleton instance exists then we'll just return it

		if($reuseInstance && isset($this->instances[$class]))
		{
			return $this->instances[$class];
		}

		// Create new instance

		$instance = $this->factory($this->resolveHint($class), $parameters);

		// Store the instance if its registered as a singleton

		if($reuseInstance && isset($this->hints[$class]) && $this->hints[$class]['singleton'])
		{
			$this->instances[$class] = $instance;
		}

		// Return the instance

		return $instance;
	}
983559
public function parseClass($class)
    {
        $reflectionClass = new ReflectionClass($class);

        // check if class is entity
        if ($this->reader->getClassAnnotation($reflectionClass, '\ProAI\Datamapper\Annotations\Entity')) {
            return $this->parseEntity($class);
        } else {
            return null;
        }
    }
468200
public static function newObject(string $class, array $args = [], $callGetClass = false)
    {
        $class = $callGetClass ? static::getClass($class) : $class;
        $rc = new \ReflectionClass($class);
        return $rc->newInstanceArgs($args);
    }
106862
public function offsetGet($class)
	{
		if (!isset($this->factories[$class]) && !isset($this->instances[$class])) {
			throw new \InvalidArgumentException("$class has not been defined");
		}

		if (isset($this->instances[$class])) {
			return $this->instances[$class];
		}

		array_push($this->resolving, $class);
		$object = $this->invoke($this->factories[$class]);
		array_pop($this->resolving);

		return $object;
	}
410529
static function forceInstance(Singleton $object, $class = null)
	{
		if($class == null)
			$class = get_class($object);
		
		if(!isset(self::$instances[$class]))
		{
			self::$instances[$class] = $object;
		}
		else
		{
			throw new \Exception(sprintf('Object of class %s was previously instanciated', $class));
		}
	}
666881
public function get(string $object)
    {
        return ($this->exists($object)) ? $this->registry[$object] : null;
    }