src/Dependency/Container.php
public function attach($key, $instance, $type = self::OBJECT)
    {
        switch ($type) {
            case self::OBJECT:
            case self::CACHE:
                if (!is_object($instance)) {
                    throw new \LogicException('Instance is not an object!');
                }
                break;
            case self::DATABASE:
                if (!($instance instanceof \PDO)) {
                    throw new \LogicException();
                }
                break;
        }

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

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

        return $this;
    }
public function attach($key, $instance, $type = self::OBJECT)
    {
        switch ($type) {
            case self::OBJECT:
            case self::CACHE:
                if (!is_object($instance)) {
                    throw new \LogicException('Instance is not an object!');
                }
                break;
            case self::DATABASE:
                if (!($instance instanceof \PDO)) {
                    throw new \LogicException();
                }
                break;
        }

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

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

        return $this;
    }
Attach new instance of any class to this container.

@param  string $key Key name to retrieve the instance
@param  object $instance Instance to attach
@param  string $type Type of object
@return self
@throws \LogicException