protected function filterCollection($collection) { if (!$collection instanceof Traversable && !is_array($collection)) { throw new InvalidArgumentException('The collection must be a Traversable object or an array'); } return $collection; }