Skip to content

Commit

Permalink
Merge pull request #25 from norzechowicz/naming
Browse files Browse the repository at this point in the history
Deprecated PropertyMatcher and match function
  • Loading branch information
defrag committed Sep 8, 2014
2 parents f92fb38 + c24b5e6 commit 5210c93
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 38 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
"dev-master": "1.2-dev"
}
}
}
3 changes: 3 additions & 0 deletions match.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
);
}

/**
* @deprecated since 1.1, to be removed in 2.0. Use SimpleFactory and object approach instead
*/
if (!function_exists('match')) {
/**
* @param mixed $value
Expand Down
8 changes: 4 additions & 4 deletions src/Coduo/PHPMatcher/Matcher.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php
namespace Coduo\PHPMatcher;

use Coduo\PHPMatcher\Matcher\PropertyMatcher;
use Coduo\PHPMatcher\Matcher\ValueMatcher;

class Matcher
{
/**
* @var Matcher\PropertyMatcher
* @var ValueMatcher
*/
private $matcher;

/**
* @param PropertyMatcher $matcher
* @param ValueMatcher $matcher
*/
public function __construct(PropertyMatcher $matcher)
public function __construct(ValueMatcher $matcher)
{
$this->matcher = $matcher;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Coduo/PHPMatcher/Matcher/ArrayMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class ArrayMatcher extends Matcher
private $accessor;

/**
* @param PropertyMatcher $propertyMatcher
* @param ValueMatcher $propertyMatcher
*/
public function __construct(PropertyMatcher $propertyMatcher)
public function __construct(ValueMatcher $propertyMatcher)
{
$this->propertyMatcher = $propertyMatcher;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Coduo/PHPMatcher/Matcher/ChainMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
class ChainMatcher extends Matcher
{
/**
* @var array|PropertyMatcher[]
* @var array|ValueMatcher[]
*/
private $matchers;

/**
* @param array|PropertyMatcher[] $matchers
* @param array|ValueMatcher[] $matchers
*/
public function __construct(array $matchers = array())
{
$this->matchers = $matchers;
}

/**
* @param PropertyMatcher $matcher
* @param ValueMatcher $matcher
*/
public function addMatcher(PropertyMatcher $matcher)
public function addMatcher(ValueMatcher $matcher)
{
$this->matchers[] = $matcher;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Coduo/PHPMatcher/Matcher/JsonMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class JsonMatcher extends Matcher
private $matcher;

/**
* @param PropertyMatcher $matcher
* @param ValueMatcher $matcher
*/
public function __construct(PropertyMatcher $matcher)
public function __construct(ValueMatcher $matcher)
{
$this->matcher = $matcher;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Coduo/PHPMatcher/Matcher/Matcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Coduo\PHPMatcher\Matcher;

abstract class Matcher implements PropertyMatcher
abstract class Matcher implements ValueMatcher
{
/**
* @var string|null
Expand Down
28 changes: 4 additions & 24 deletions src/Coduo/PHPMatcher/Matcher/PropertyMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,9 @@

namespace Coduo\PHPMatcher\Matcher;

interface PropertyMatcher
/**
* @deprecated since 1.1, to be removed in 2.0. Use ValueMatcher instead
*/
interface PropertyMatcher extends ValueMatcher
{
/**
* Matches value against the pattern
*
* @param $value
* @param $pattern
* @return boolean
*/
public function match($value, $pattern);

/**
* Checks if matcher can match the pattern
*
* @param $pattern
* @return boolean
*/
public function canMatch($pattern);

/**
* Returns a string description why matching failed
*
* @return null|string
*/
public function getError();
}
30 changes: 30 additions & 0 deletions src/Coduo/PHPMatcher/Matcher/ValueMatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Coduo\PHPMatcher\Matcher;

interface ValueMatcher
{
/**
* Matches value against the pattern
*
* @param $value
* @param $pattern
* @return boolean
*/
public function match($value, $pattern);

/**
* Checks if matcher can match the pattern
*
* @param $pattern
* @return boolean
*/
public function canMatch($pattern);

/**
* Returns a string description why matching failed
*
* @return null|string
*/
public function getError();
}

0 comments on commit 5210c93

Please sign in to comment.