/** * @covers ::map */ public function testMap() { $source = [new Model(['name' => 'test1']), new Model(['name' => 'test1']), new Model(['name' => 'test2'])]; $models = new Models($source); $result = $models->map(function ($model) { return $model->name; }); $this->assertEquals(['test1', 'test1', 'test2'], $result); }
/** * Call a closure for each model, return the results as an array * * @param Closure $closure * @return array */ public function map(Closure $closure) { return $this->current->map($closure); }