public function resolve(string $class, array $rules = [])
    {
        //reset tree;
        $this->tree = [];

        //merge rules passed as parameter with general rules
        $this->rules = \array_merge($this->rules, $rules);

        //build dependency tree
        $this->buildTree($class);

        //build objects
        $this->buildObjects();

        //return required class
        return $this->cache[$class] ?? null;
    }