How to refactor this snippet of code, to reduce indentation level by one? I just wonder is it possible in PHP to write this code in a diffrent way, with just one level of indentation.
The code:
private function isArrayMatchingCriteria(array $array) {
foreach($array as $element) {
if (! $this->isElementMatchingCriteria($element) {
return false;
}
}
return true;
}
Please take into consideration, that:
- this code doesn't always iterate over all array elements - so combination of count + array_filter / array_map isn't the same
- it is easy to do by introducing a dedicated object attribute serving as a flag, but I'm looking for a way without introducing new attributes