PhpSpec\Runner\CollaboratorManager::get PHP Method

get() public method

public get ( string $name ) : Collaborator
$name string
return PhpSpec\Wrapper\Collaborator
    public function get($name)
    {
        if (!$this->has($name)) {
            throw new CollaboratorException(sprintf('Collaborator %s not found.', $this->presenter->presentString($name)));
        }
        return $this->collaborators[$name];
    }

Usage Example

コード例 #1
0
 /**
  * @param CollaboratorManager $collaborators
  * @param string              $name
  *
  * @return Collaborator
  */
 private function getOrCreateCollaborator(CollaboratorManager $collaborators, $name)
 {
     if (!$collaborators->has($name)) {
         $collaborator = new Collaborator($this->prophet->prophesize());
         $collaborators->set($name, $collaborator);
     }
     return $collaborators->get($name);
 }