public function get($keyOrItem)
    {
        $id = $this->dependency->getId($keyOrItem);

        if ($this->resolved->has($id)) {
            return $this->resolved[$id];
        }

        $deps = new MutableBag();

        $thisDeps = $this->dependency->getDependencies($keyOrItem);

        foreach ($thisDeps as $dep) {
            try {
                $this->dependency->verify($dep);
            } catch (UnknownDependencyException $e) {
                $e->setItem($id);
                throw $e;
            }
            $depId = $this->dependency->getId($dep);

            if (!$deps->hasItem($depId)) {
                $deps[] = $depId;
            }

            if ($this->resolving->has($depId)) {
                throw new CyclicDependencyException($this->resolving->keys()->toArray());
            }

            $this->resolving[$depId] = true;
            try {
                $deps = $deps->merge($this->get($dep));
            } finally {
                $this->resolving->remove($depId);
            }
        }

        $this->resolved[$id] = $deps->unique()->immutable();

        return $deps;
    }
public function get($keyOrItem)
    {
        $id = $this->dependency->getId($keyOrItem);

        if ($this->resolved->has($id)) {
            return $this->resolved[$id];
        }

        $deps = new MutableBag();

        $thisDeps = $this->dependency->getDependencies($keyOrItem);

        foreach ($thisDeps as $dep) {
            try {
                $this->dependency->verify($dep);
            } catch (UnknownDependencyException $e) {
                $e->setItem($id);
                throw $e;
            }
            $depId = $this->dependency->getId($dep);

            if (!$deps->hasItem($depId)) {
                $deps[] = $depId;
            }

            if ($this->resolving->has($depId)) {
                throw new CyclicDependencyException($this->resolving->keys()->toArray());
            }

            $this->resolving[$depId] = true;
            try {
                $deps = $deps->merge($this->get($dep));
            } finally {
                $this->resolving->remove($depId);
            }
        }

        $this->resolved[$id] = $deps->unique()->immutable();

        return $deps;
    }
public function get ( $ keyOrItem ) { $ id = $ this -> dependency -> getId ( $ keyOrItem ) ; if ( $ this -> resolved -> has ( $ id ) ) { return $ this -> resolved [ $ id ] ; } $ deps = new MutableBag ( ) ; $ thisDeps = $ this -> dependency -> getDependencies ( $ keyOrItem ) ; foreach ( $ thisDeps as $ dep ) { try { $ this -> dependency -> verify ( $ dep ) ; } catch ( UnknownDependencyException $ e ) { $ e -> setItem ( $ id ) ; throw $ e ; } $ depId = $ this -> dependency -> getId ( $ dep ) ; if ( ! $ deps -> hasItem ( $ depId ) ) { $ deps [ ] = $ depId ; } if ( $ this -> resolving -> has ( $ depId ) ) { throw new CyclicDependencyException ( $ this -> resolving -> keys ( ) -> toArray ( ) ) ; } $ this -> resolving [ $ depId ] = true ; try { $ deps = $ deps -> merge ( $ this -> get ( $ dep ) ) ; } finally { $ this -> resolving -> remove ( $ depId ) ; } } $ this -> resolved [ $ id ] = $ deps -> unique ( ) -> immutable ( ) ; return $ deps ; }
Return all of the dependencies for the given key or item.

@param mixed $keyOrItem

@return mixed[]|Bag
Return all of the dependencies for the given key or item .