-
-
Notifications
You must be signed in to change notification settings - Fork 85
Allow to mark JSON properties & XML nodes as optional #102
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
Changes from 9 commits
4c78197
d6ec56c
ff9ab1a
ef29d68
b780687
3de0aab
c8e0045
12c60ce
a454c90
1df7251
a50d669
1088d4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,4 +51,12 @@ public function getError() | |
{ | ||
return $this->error; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'inArray'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please make constant from those names? For example:
This should allow to use constants here https://github.com/coduo/php-matcher/blob/master/src/Parser/ExpanderInitializer.php#L18 You can also replace |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Coduo\PHPMatcher\Matcher\Pattern\Expander; | ||
|
||
use Coduo\PHPMatcher\Matcher\Pattern\PatternExpander; | ||
|
||
final class Optional implements PatternExpander | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function match($value) | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getError() | ||
{ | ||
return null; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'optional'; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@norzechowicz I'm not pretty sure that we must check if values match to pattern because it already hasn't
array_diff_key($pattern, $values)
and also because OptionalExpander works only with top level match