public function testMap() { $this->coll->add(1)->add(2)->add(3); $coll = $this->coll->map(function ($item) { return $item * 2; }); $expected = new ArrayList([2, 4, 6]); $this->assertSame($expected->toArray(), $coll->toArray()); }
public function allWithSubtasks(WList $list) { $tasks = new ArrayList($this->all($list)); $tasksWithSubtaks = $tasks->map(function (Task $task) { return $task->setSubtasks($this->subtaskService->forTask($task)); }); return $tasksWithSubtaks; }
/** * {@inheritdoc} */ public static function open(string $filepath) : DocumentInterface { $document = new static(); $document->documentAdapter = PHPExcel_IOFactory::load($filepath); $worksheets = new ArrayList($document->documentAdapter->getSheetNames()); $document->worksheets = $worksheets->map(function (string $sheetName) use($document) { return new Worksheet($document->documentAdapter->getSheetByName($sheetName)); }); return $document; }