/** * @return mixed */ public function execute() { if ($this->collection instanceof PipelineInterface) { $collection = $this->collection->execute(); if (!$collection instanceof CollectionInterface) { throw new \UnexpectedValueException('Expecting an instance of ' . CollectionInterface::class); } } else { $collection = $this->collection; } return call_user_func($this->callback, $collection); }