Skip to content
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

Array repeat expander not working #157

Closed
Linkinou opened this issue Jul 12, 2019 · 2 comments
Closed

Array repeat expander not working #157

Linkinou opened this issue Jul 12, 2019 · 2 comments

Comments

@Linkinou
Copy link

Linkinou commented Jul 12, 2019

Hello there,

I'm trying to understand how to work with array repeat expander.

I tried to match this :

 [
     {
         "label": "Hello world !"
     }
 ]

with this :

'@[email protected]({\"label\": \"@string@\"})'

but got this :

Type pattern "@array@" is not supported by TextMatcher.

Am I missing something ?

I'm using PHP 7.1 and coduo/php-matcher 3.1

@teklakct
Copy link
Contributor

teklakct commented Aug 7, 2019

"Type pattern "@array@" is not supported by TextMatcher." You're using a TextMatcher which obviously matches text, not arrays. For this what you need try to use JsonMatcher.
Note that the pattern should be wrapped in quotes.

$value = '[{"label": "Hello world !"}]';
$pattern = '"@[email protected]({\"label\": \"@string@\"})"';

$matcher->match($value, $pattern);

@norberttech norberttech pinned this issue Aug 7, 2019
@Linkinou
Copy link
Author

Linkinou commented Aug 8, 2019

Thank you @teklakct
Actually I was using the SimpleFactory thinking that it will give me a JsonMatcher automatically (based on the given value).

So I guess I have to create a JsonMatcher like here ? https://github.com/coduo/php-matcher/blob/master/tests/Matcher/JsonMatcherTest.php#L19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants