-
Notifications
You must be signed in to change notification settings - Fork 9
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
Chain multiple comparision expressions #6
base: master
Are you sure you want to change the base?
Chain multiple comparision expressions #6
Conversation
Add getters for Path attributes
…tiple_or_conditions Fix scim filtering to allow multiple or conditions
…unction or a disjunction
{ | ||
$this->terms[] = $term; | ||
} | ||
|
||
/** | ||
* @return Term[] | ||
* @return Filter[] | ||
*/ | ||
public function getTerms() |
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.
Assuming changing this from Term[]
to Filter[]
doesn't break anything, I would suggest renaming this to getFilters()
.
@@ -13,11 +13,11 @@ | |||
|
|||
class Disjunction extends Filter | |||
{ | |||
/** @var Term[] */ | |||
/** @var Filter[] */ | |||
private $terms = []; |
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.
I would rename this to $filters
.
private $terms = []; | ||
|
||
/** | ||
* @param Term[] $terms | ||
* @param Filter[] $terms |
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.
Same goes for this one, I would rename to $filters
*/ | ||
public function add(Term $term) | ||
public function add(Filter $term) |
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.
Same goes for this one, I would rename to $filter
|
||
/** | ||
* @return AttributePath | ||
*/ | ||
public function getAttributePath() | ||
{ | ||
return $this->attributePath; | ||
} | ||
|
||
/** | ||
* @return ValuePath | ||
*/ | ||
public function getValuePath() | ||
{ | ||
return $this->valuePath; | ||
} |
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.
There's already a pending PR for this one: #7
if ($this->lexer->isNextToken(Tokens::T_SP)) { | ||
$isNextTokenOr = true; | ||
while($this->lexer->isNextToken(Tokens::T_SP) && $isNextTokenOr) { | ||
$nextToken = $this->lexer->glimpse(); | ||
if ($this->isName('or', $nextToken)) { | ||
$this->match(Tokens::T_SP); | ||
$this->match(Tokens::T_NAME); | ||
$this->match(Tokens::T_SP); | ||
$terms[] = $this->conjunction(); | ||
} else { | ||
$isNextTokenOr = false; | ||
} | ||
} |
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.
Instead of using a variable to break the while
loop, simply use the break
statement instead.
while ($this->lexer->isNextToken(Tokens::T_SP)) {
$nextToken = $this->lexer->glimpse();
if ($this->isName('or', $nextToken) === false) {
break;
}
$this->match(Tokens::T_SP);
$this->match(Tokens::T_NAME);
$this->match(Tokens::T_SP);
$terms[] = $this->conjunction();
}
if ($this->lexer->isNextToken(Tokens::T_SP)) { | ||
$isNextTokenAnd = true; | ||
while($this->lexer->isNextToken(Tokens::T_SP) && $isNextTokenAnd) { | ||
$nextToken = $this->lexer->glimpse(); | ||
if ($this->isName('and', $nextToken)) { | ||
$this->match(Tokens::T_SP); | ||
$this->match(Tokens::T_NAME); | ||
$this->match(Tokens::T_SP); | ||
$factors[] = $this->factor(); | ||
} else { | ||
$isNextTokenAnd = false; | ||
} | ||
} |
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.
Same goes for this one:
while ($this->lexer->isNextToken(Tokens::T_SP)) {
$nextToken = $this->lexer->glimpse();
if ($this->isName('and', $nextToken) === false) {
break;
}
$this->match(Tokens::T_SP);
$this->match(Tokens::T_NAME);
$this->match(Tokens::T_SP);
$factors[] = $this->factor();
}
@dbollaer Well this repository isn't mine so don't ask me haha. Given the last release was in 2017, I doubt it though. Shameless plug but you could try mine if you like: https://github.com/Cloudstek/scim-filter-parser |
Noice, thanks @mdeboer! Appreciate that you've taken the helm of this 🙏 |
Added the possiblity to chain multiple comparision expression in a single Disjunction/Conjunction