public function FilterComposite::filter in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-hydrator/src/Filter/FilterComposite.php \Zend\Hydrator\Filter\FilterComposite::filter()
Filter the composite based on the AND and OR condition Will return true if one from the "or conditions" and all from the "and condition" returns true. Otherwise false
Parameters
$property string Parameter will be e.g. Parent\Namespace\Class::method:
Return value
bool
Overrides FilterInterface::filter
File
- vendor/
zendframework/ zend-hydrator/ src/ Filter/ FilterComposite.php, line 153
Class
Namespace
Zend\Hydrator\FilterCode
public function filter($property) {
$andCount = count($this->andFilter);
$orCount = count($this->orFilter);
// return true if no filters are registered
if ($orCount === 0 && $andCount === 0) {
return true;
}
elseif ($orCount === 0 && $andCount !== 0) {
$returnValue = true;
}
else {
$returnValue = false;
}
// Check if 1 from the or filters return true
foreach ($this->orFilter as $filter) {
if (is_callable($filter)) {
if ($filter($property) === true) {
$returnValue = true;
break;
}
continue;
}
else {
if ($filter
->filter($property) === true) {
$returnValue = true;
break;
}
}
}
// Check if all of the and condition return true
foreach ($this->andFilter as $filter) {
if (is_callable($filter)) {
if ($filter($property) === false) {
return false;
}
continue;
}
else {
if ($filter
->filter($property) === false) {
return false;
}
}
}
return $returnValue;
}