Skip to content

Commit 1c961e3

Browse files
committed
Adding wildcard matcher
1 parent 6becf62 commit 1c961e3

12 files changed

+48
-20
lines changed

src/JsonMatcher/Matcher.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@ public function canMatch($pattern)
2525
return true;
2626
}
2727

28-
29-
}
28+
}

src/JsonMatcher/Matcher/ArrayMatcher.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public function canMatch($pattern)
5959
return is_array($pattern);
6060
}
6161

62-
6362
private function buildPath(array $array, $parentPath)
6463
{
6564
foreach ($array as $key => $element) {

src/JsonMatcher/Matcher/ChainMatcher.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,11 @@ public function canMatch($pattern)
3535
return true;
3636
}
3737

38-
3938
/**
4039
* {@inheritDoc}
4140
*/
4241
public function getName()
4342
{
4443
return 'chain';
4544
}
46-
}
45+
}

src/JsonMatcher/Matcher/PropertyMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ public function match($matcher, $pattern);
88

99
public function canMatch($pattern);
1010

11-
}
11+
}

src/JsonMatcher/Matcher/ScalarMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ public function canMatch($pattern)
1818
return is_scalar($pattern);
1919
}
2020

21-
}
21+
}

src/JsonMatcher/Matcher/TypeMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ private function extractType($pattern)
2323
return str_replace("@", "", $pattern);
2424
}
2525

26-
}
26+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace JsonMatcher\Matcher;
4+
5+
class WildcardMatcher implements PropertyMatcher
6+
{
7+
/**
8+
* {@inheritDoc}
9+
*/
10+
public function match($matcher, $pattern)
11+
{
12+
return true;
13+
}
14+
15+
public function canMatch($pattern)
16+
{
17+
return '*' === $pattern;
18+
}
19+
20+
}

src/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
}
2424

2525
return false;
26-
});
26+
});

tests/JsonMatcher/ArrayMatcherTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php
22
namespace JsonMatcher\Tests;
33

44
use JsonMatcher\Matcher\ArrayMatcher;
@@ -36,8 +36,6 @@ public function test_match_arrays()
3636
$chain->addMatcher(new ScalarMatcher());
3737
$matcher = new ArrayMatcher($chain);
3838

39-
40-
4139
$this->assertTrue($matcher->match($this->simpleArray, $this->simpleArray));
4240
$this->assertTrue($matcher->match([], []));
4341
$this->assertFalse($matcher->match($this->simpleArray, []));
@@ -57,5 +55,4 @@ public function test_match_arrays()
5755
]));
5856
}
5957

60-
6158
}

tests/JsonMatcher/MatcherTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
<?php
1+
<?php
22
namespace JsonMatcher\Tests;
33

4-
use JsonMatcher\Matcher;
5-
64
class MatcherTest extends \PHPUnit_Framework_TestCase
75
{
86
public function test_foo()
97
{
108
$this->assertTrue(true);
119
}
12-
}
10+
}

0 commit comments

Comments
 (0)