PhpSpec\Runner\MatcherManager::add PHP Method

add() public method

public add ( PhpSpec\Matcher\Matcher $matcher )
$matcher PhpSpec\Matcher\Matcher
    public function add(Matcher $matcher)
    {
        $this->matchers[] = $matcher;
        @usort($this->matchers, function (Matcher $matcher1, Matcher $matcher2) {
            return $matcher2->getPriority() - $matcher1->getPriority();
        });
    }

Usage Example

 /**
  *
  * @param ExampleNode $example        	
  * @param SpecificationInterface $context        	
  * @param MatcherManager $matchers        	
  * @param CollaboratorManager $collaborators        	
  */
 public function prepare(ExampleNode $example, SpecificationInterface $context, MatcherManager $matchers, CollaboratorManager $collaborators)
 {
     $matchers->replace($this->defaultMatchers);
     if (!$context instanceof Matcher\MatchersProviderInterface) {
         return;
     }
     foreach ($context->getMatchers() as $name => $matcher) {
         if ($matcher instanceof Matcher\MatcherInterface) {
             $matchers->add($matcher);
         } else {
             $matchers->add(new Matcher\CallbackMatcher($name, $matcher, $this->presenter));
         }
     }
 }
All Usage Examples Of PhpSpec\Runner\MatcherManager::add