@param $instance

@return bool
961016
public function isProvider($instance)
    {
        $interfaces = class_implements($instance);

        if (isset($interfaces[AbstractProviderInterface::class])) {
            return true;
        }

        return false;
    }
1161212
public static function setInstance($instance)
    {
        if ($instance === null) {
            unset(Yii::getApp()->loadedModules[static::class]);
        } else {
            Yii::getApp()->loadedModules[\get_class($instance)] = $instance;
        }
    }
80073
public function validateObject($instance)
    {
        if (null !== $this->validator) {
            $violations = $this->validator->validate($instance);

            if (!empty($violations)) {
                throw new ValidationException($violations);
            }
        }
    }
552302
public function load($module, $instance = null)
    {
        if ( ! is_null($instance))
        {
            if ( ! $this->hasModule($module))
            {
                $this->addModule($module);
            }

            return ($this->instances[$module] = $instance);
        }

        if ($this->hasModule($module))
        {
            return ($this->instances[$module] = new $module);
        }

        throw new UnexpectedValueException("Module {$module} does not exist");
    }
1188374
protected function isPublished(DataObject $instance)
    {
        $isPublished = false;
        if ($instance->hasMethod('isPublished')) {
            $isPublished = $instance->isPublished();
        }
        return $isPublished;
    }
325570
private function getInstanceCode(Instance $instance) : Code
    {
        $node = ($this->normalizer)($instance->value);

        return new Code(new Node\Stmt\Return_($node), false);
    }
223112
public static function setInstance($instance)
    {
        if ($instance === null) {
            unset(Zilf::$app->loadedModules[get_called_class()]);
        } else {
            Zilf::$app->loadedModules[get_class($instance)] = $instance;
        }
    }
970673
public function model($instance = false)
	{
		if (! isset($this->model)) {
			throw new \InvalidArgumentException(static::class . ' does not implement a model definition.');
		}

		return $instance ? new $this->model : $this->model;
	}
177003
public function instance($abstract, $instance)
    {
        $abstract = $this->normalize($abstract);
        if (is_array($abstract)) {
            list($abstract, $alias) = $this->extractAlias($abstract);
            $this->alias($abstract, $alias);
        }
        unset($this->aliases[$abstract]);
        $bound = $this->bound($abstract);

        $this->instances[$abstract] = $instance;
        if ($bound) {
            $this->rebound($abstract);
        }
    }
452960
public function can_hide_show_instance($instance) {
        $context = context_course::instance($instance->courseid);
        if (!has_capability('enrol/guest:config', $context)) {
            return false;
        }

        // If the instance is currently disabled, before it can be enabled, we must check whether the password meets the
        // password policies.
        if ($instance->status == ENROL_INSTANCE_DISABLED) {
            if ($this->get_config('requirepassword')) {
                if (empty($instance->password)) {
                    return false;
                }
            }

            // Only check the password if it is set.
            if (!empty($instance->password) && $this->get_config('usepasswordpolicy')) {
                if (!check_password_policy($instance->password, $errmsg)) {
                    return false;
                }
            }
        }

        return true;
    }
544757
public function created($instance)
    {
        $after = $this->recordableAttributes(get_class($instance), $instance->getAttributes());

        $instance->recordActivity('created', null, $after);
    }
1234506
public function instance($instance = null)
    {
        $instance = $instance ?: self::DEFAULT_INSTANCE;

        $this->instance = sprintf('%s.%s', 'cart', $instance);

        return $this;
    }
59819
public function delete($instance)
    {
        $collection = $instance instanceof Document ? [$instance] : $instance;

        $key = $this->key();
        if (!$key) {
          throw new ORMException("No primary key has been defined for `" + instance.self() + "`'s schema.");
        }

        $keys = [];

        foreach ($collection as $entity) {
            $entity->sync();
            if ($entity->exists()) {
                $keys[] = $entity->id();
            }
        }

        if (!$keys) {
            return true;
        }

        if (!$this->remove([$key => (count($keys) ===1 ? $keys[0] : $keys)])) {
            return false;
        }

        foreach ($collection as $entity) {
            $entity->amend([], ['exists' => false]);
        }

        return true;
    }
1226528
public function has($name)
    {
        if (! isset($this->instances[$name])) {
            return isset($this->registry[$name]);
        }

        return true;
    }
521594
public function removeInstance(WidgetInstance $instance)
    {
        if ($this->instances->contains($instance)) {
            $this->instances->removeElement($instance);
        }
    }
1196822
protected function exists($id, $instanceName)
    {
        return $this->getConnection()->table($this->getTableName())
            ->where('id', $id)
            ->where('instance', $instanceName)
            ->exists();
    }
914968
public function get($instanceName) {
		if (!isset($this->objectInstances[$instanceName]) || $this->objectInstances[$instanceName] == null) {
			$this->instantiateComponent($instanceName);
		}
		return $this->objectInstances[$instanceName];
	}