json-logic-php
json-logic-php copied to clipboard
Updated to support various array conditions
Hello! Very impressed by JSON Logic – It works exceptionally well. Great work!
I added a few operators for evaluating array conditions. These seem to be working well for my needs and I wanted to submit them as a pull request.
Hopefully these are helpful and, if so, can be incorporated. Thanks for your time and consideration!
Hey, sorry if you're getting weird cross notifications, I've never seen that happen between repos before.
This looks like good functionality to add with two caveats:
- Would it be possible for you to create some unit tests? If you run phpunit it'll download the shared tests from jsonlogic.com into
tests/tests.json
. You can append to the bottom. The basic format is that the whole file is an array. Comments are strings, and tests are an array of rule, data, expected outcome. I can use the unit tests to build the matching functionality in the JS library. In PHP every rule gets run twice, once with json_decode using PHP associative arrays, and once using PHP objects. - I'm starting to think about having some light weight name spaces around functionality groups. The original idea came from this issue https://github.com/jwadhams/json-logic-js/issues/3 but I think it would make the library easier to grok even for new "native" functionality. So something like renaming these functions
array.compare
andarray.key_exists
? (That would suggest I should alias or rename the functionsarray.merge
andarray.in
)