Skip to content
Browse files

simplified matcher interface

removed parameters argument from supports() as it
complicated interface a lot without real visible
benefits
  • Loading branch information...
1 parent baac876 commit cf490efc77790e16ca74acd46b0c0b518df2475b @everzet everzet committed
View
4 src/PHPSpec2/Matcher/BooleanMatcher.php
@@ -6,11 +6,11 @@
class BooleanMatcher extends BasicMatcher
{
- public function supports($subject, $keyword, array $parameters)
+ public function supports($subject, $keyword)
{
return in_array($keyword, array('be'))
&& is_object($subject)
- && 1 == count($parameters);
+ ;
}
protected function matches($subject, array $parameters)
View
5 src/PHPSpec2/Matcher/CountMatcher.php
@@ -8,10 +8,9 @@
class CountMatcher extends BasicMatcher
{
- public function supports($subject, $keyword, array $parameters)
+ public function supports($subject, $keyword)
{
- return in_array($keyword, array('contain', 'have'))
- && (count($parameters) > 0 && count($parameters) < 3);
+ return in_array($keyword, array('contain', 'have'));
}
protected function matches($subject, array $parameters)
View
5 src/PHPSpec2/Matcher/EqualityMatcher.php
@@ -6,10 +6,9 @@
class EqualityMatcher extends BasicMatcher
{
- public function supports($subject, $keyword, array $parameters)
+ public function supports($subject, $keyword)
{
- return in_array($keyword, array('eql', 'equal', 'be_equal', 'equal_to', 'be_equal_to'))
- && 1 == count($parameters);
+ return in_array($keyword, array('eql', 'equal', 'be_equal', 'equal_to', 'be_equal_to'));
}
protected function matches($subject, array $parameters)
View
5 src/PHPSpec2/Matcher/MatcherInterface.php
@@ -5,15 +5,14 @@
interface MatcherInterface
{
/**
- * Checks if matcher supports provided subject, name and parameters.
+ * Checks if matcher supports provided subject and matcher name.
*
* @param mixed $subject
* @param string $name
- * @param array $parameters
*
* @return Boolean
*/
- public function supports($subject, $name, array $parameters);
+ public function supports($subject, $name);
/**
* Evaluates positive match.
View
14 src/PHPSpec2/Matcher/MatchersCollection.php
@@ -13,19 +13,19 @@ public function add(MatcherInterface $matcher)
$this->matchers[] = $matcher;
}
- public function getAll()
- {
- return $this->matchers;
- }
-
- public function findFirst($subject, $keyword, array $arguments)
+ public function find($subject, $keyword)
{
foreach ($this->matchers as $matcher) {
- if ($matcher->supports($subject, $keyword, $arguments)) {
+ if ($matcher->supports($subject, $keyword)) {
return $matcher;
}
}
throw new MatcherNotFoundException($keyword);
}
+
+ public function getAll()
+ {
+ return $this->matchers;
+ }
}
View
2 src/PHPSpec2/Stub/Verification.php
@@ -19,7 +19,7 @@ public function __construct($subject, MatchersCollection $matchers, $positive)
public function __call($name, array $arguments = array())
{
- $matcher = $this->matchers->findFirst($this->subject, $name, $arguments);
+ $matcher = $this->matchers->find($this->subject, $name);
if ($this->positive) {
return $matcher->positiveMatch($this->subject, $arguments);

0 comments on commit cf490ef

Please sign in to comment.
Something went wrong with that request. Please try again.