public function clearExcept(array $keep): void
    {
        $kept = [];
        foreach ($keep as $name) {
            $name = $this->getDefinitiveName($name);

            if (!$this->has($name)) {
                throw NotFoundException::fromId($name);
            }

            $kept[$name] = $this->get($name);
        }

        $this->instances = $kept;
    }
public function clearExcept(array $keep): void
    {
        $kept = [];
        foreach ($keep as $name) {
            $name = $this->getDefinitiveName($name);

            if (!$this->has($name)) {
                throw NotFoundException::fromId($name);
            }

            $kept[$name] = $this->get($name);
        }

        $this->instances = $kept;
    }
public function clearExcept ( array $ keep ) : void { $ kept = [ ] ; foreach ( $ keep as $ name ) { $ name = $ this -> getDefinitiveName ( $ name ) ; if ( ! $ this -> has ( $ name ) ) { throw NotFoundException :: fromId ( $ name ) ; } $ kept [ $ name ] = $ this -> get ( $ name ) ; } $ this -> instances = $ kept ; }
Clear all instances except those provided.

@param string[] $keep

@throws ContainerException
@throws NotFoundException
Clear all instances except those provided .