/**
  * Notify the Expectation of an Invocation and check if it matches.
  * @param Yay_Invocation $invocation
  * @return boolean
  */
 public function isExpected(Yay_Invocation $invocation)
 {
     $matches = true;
     $object = $invocation->getObject();
     if ($object === $this->_object) {
         if (isset($this->_statePredicate)) {
             $matches = $this->_statePredicate->isActive();
         }
         if ($matches && isset($this->_method)) {
             if ($this->_method == $invocation->getMethod()) {
                 $args =& $invocation->getArguments();
                 foreach ($this->_matchers as $i => $m) {
                     if (!array_key_exists($i, $args)) {
                         if ($m->isOptional()) {
                             break;
                         } else {
                             $matches = false;
                             break;
                         }
                     } else {
                         if (!$m->matches($args[$i])) {
                             $matches = false;
                             break;
                         }
                     }
                 }
             } else {
                 $matches = false;
             }
         }
         if ($matches && isset($this->_sequence)) {
             $matches = $this->_sequence->isInSequence($this->_wantedSequenceId);
         }
     } else {
         $matches = false;
     }
     if ($matches) {
         $this->notifyMatchedInvocation($invocation);
     }
     return $matches;
 }