/** * @return Range[]|Range\Collection */ public function aggregate() { $aggregator = new Aggregator(); $this->traverseWith(function (Codepoint $codepoint) use($aggregator) { $aggregator->addCodepoint($codepoint); }); return $aggregator->getAggregated(); }
/** * @param callable $comparator * @param Exception $notFoundException * @return Range[]|Range\Collection * @throws Exception */ private function aggregatePropertiesWith(callable $comparator, Exception $notFoundException) { $aggregator = new Aggregator(); foreach ($this->getAll() as $item) { if (call_user_func($comparator, $item) === true) { $codepoint = $item->getCodepoint(); $aggregator->addCodepoint($codepoint); } } if ($aggregator->hasAggregated() !== true) { throw $notFoundException; } return $aggregator->getAggregated(); }