Skip to content
Snippets Groups Projects
Commit af965956 authored by Sebastien ANDRE's avatar Sebastien ANDRE
Browse files

Merge branch 'fix_error_on_storm_query' into 'master'

[RTOK] remove dead code on criteria and refacto

See merge request !67
parents b7678208 75b0aa4f
1 merge request!67[RTOK] remove dead code on criteria and refacto
Pipeline #35366 passed with stage
in 2 minutes and 45 seconds
......@@ -179,29 +179,17 @@ class Storm_Query_Criteria implements Storm_Query_CriteriaInterface {
}
protected function _containsAllAttributesForAnd(array $model) : bool {
return null === (new Storm_Collection($this->_clauses))
->reject(fn($clause) => $clause instanceof Storm_Query_Sub)
->detect(fn($clause) => ! $this->_containsOne($clause, $model));
foreach ($this->_clauses as $clause)
if ( ! $this->_containsOne($clause, $model))
return false;
return true;
protected function _containsAllAttributesForAnd(array $model): bool
{
return null === $this->_clausesWithoutSub()
->detect(fn($clause) => ! $this->_containsOne($clause, $model));
}
protected function _containsAllAttributesForOr(array $model) : bool {
return null !== (new Storm_Collection($this->_clauses))
->reject(fn($clause) => $clause instanceof Storm_Query_Sub)
->detect(fn($clause) => $this->_containsOne($clause, $model));
foreach ($this->_clauses as $clause)
if ($this->_containsOne($clause, $model))
return true;
return false;
protected function _containsAllAttributesForOr(array $model): bool
{
return null !== $this->_clausesWithoutSub()
->detect(fn($clause) => $this->_containsOne($clause, $model));
}
......@@ -213,6 +201,13 @@ class Storm_Query_Criteria implements Storm_Query_CriteriaInterface {
}
protected function _clausesWithoutSub(): Storm_Collection
{
return (new Storm_Collection($this->_clauses))
->reject(fn($clause) => $clause instanceof Storm_Query_Sub);
}
/**
* @param $key string | Storm_Query_Key
* @param $value int | string
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment