Skip to content

Deprecated PropertyMatcher and match function #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}