Skip to content

Commit 5f77989

Browse files
committedApr 18, 2014
Updating transformpattern method
1 parent 6ebbf20 commit 5f77989

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed
 

‎src/PHPMatcher/Matcher/JsonMatcher.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
class JsonMatcher implements PropertyMatcher
66
{
7+
const REPLACE_PATTERN = '/([^"])@(integer|string|array|double|wildcard|boolean)@([^"])/';
8+
79
/**
810
* @var
911
*/
@@ -41,11 +43,19 @@ public function canMatch($pattern)
4143
private function isValidJson($string)
4244
{
4345
@json_decode($string, true);
44-
return (json_last_error() == JSON_ERROR_NONE);
46+
return (json_last_error() === JSON_ERROR_NONE);
4547
}
4648

49+
/**
50+
* Wraps placeholders which arent wrapped with quotes yet
51+
*
52+
* @param $pattern
53+
* @return mixed
54+
*/
4755
private function transformPattern($pattern)
4856
{
49-
return preg_replace('/([^"])@(integer|string|array|double|wildcard|boolean)@([^"])/', '$1"@$2@"$3', $pattern);
57+
$replacement = '$1"@$2@"$3';
58+
return preg_replace(self::REPLACE_PATTERN, $replacement, $pattern);
5059
}
60+
5161
}

0 commit comments

Comments
 (0)