public function testEach() { $collection = new Collection(array(1, 2, 3, 4)); $test = array(); $collection->each(function ($value) use(&$test) { $test[] = $value * 2; }); $this->assertEquals(array(2, 4, 6, 8), $test); }
/** * @param Collection $rules * * @return Collection|\Ciconia\Common\Tag[] */ protected function createBaseTags(Collection $rules) { /* @var Collection|Tag[] $baseTags */ $baseTags = new Collection(); $rules->each(function (Text $cell) use(&$baseTags) { $cell->trim(); $tag = new Tag('td'); if ($cell->match('/^-.*:$/')) { $tag->setAttribute('align', 'right'); } elseif ($cell->match('/^:.*:$/')) { $tag->setAttribute('align', 'center'); } $baseTags->add($tag); }); return $baseTags; }