Skip to content

Commit

Permalink
0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftCreatR committed Jun 1, 2024
1 parent a15deed commit 272173a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
run: composer update --prefer-dist --no-interaction

- name: Run phpcs
run: phpcs -- -v
run: composer cs

- name: Execute tests
run: composer test -- --coverage-clover=coverage.xml
Expand Down
9 changes: 3 additions & 6 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ include:

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "softcreatr/jsonpath",
"description": "JSONPath implementation for parsing, searching and flattening arrays",
"license": "MIT",
"version": "0.9.0",
"version": "0.9.1",
"authors": [
{
"name": "Stephen Frank",
Expand All @@ -29,7 +29,8 @@
},
"require-dev": {
"phpunit/phpunit": "10 - 12",
"roave/security-advisories": "dev-latest"
"friendsofphp/php-cs-fixer": "^3.58",
"squizlabs/php_codesniffer": "^3.10"
},
"replace": {
"flow/jsonpath": "*"
Expand All @@ -50,6 +51,8 @@
"preferred-install": "dist"
},
"scripts": {
"test": "phpunit"
"test": "phpunit",
"cs": "phpcs",
"cs-fix": "php-cs-fixer fix --config=.php-cs-fixer.dist.php"
}
}
8 changes: 7 additions & 1 deletion src/Filters/QueryMatchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Flow\JSONPath\AccessHelper;
use Flow\JSONPath\JSONPath;
use Flow\JSONPath\JSONPathException;
use RuntimeException;

class QueryMatchFilter extends AbstractFilter
Expand All @@ -19,6 +20,9 @@ class QueryMatchFilter extends AbstractFilter
(\s*(?<operator>==|=~|=|<>|!==|!=|>=|<=|>|<|in|!in|nin)\s*(?<comparisonValue>.+))?
';

/**
* @throws JSONPathException
*/
public function filter($collection): array
{
\preg_match('/^' . static::MATCH_QUERY_OPERATORS . '$/x', $this->token->value, $matches);
Expand Down Expand Up @@ -61,13 +65,15 @@ public function filter($collection): array

foreach ($collection as $value) {
$value1 = null;

if (AccessHelper::keyExists($value, $key, $this->magicIsAllowed)) {
$value1 = AccessHelper::getValue($value, $key, $this->magicIsAllowed);
} elseif (\str_contains($key, '.')) {
$value1 = (new JSONPath($value))->find($key)->getData()[0] ?? '';
}

if ($value1) {
if ($operator === null && $value1) {
if ($operator === null) {
$return[] = $value;
}

Expand Down

0 comments on commit 272173a

Please sign in to comment.