public function testContains() { $text = new \Ciconia\Common\Text('item1'); $collection = new Collection(); $collection->add($text); $this->assertTrue($collection->contains($text)); $this->assertFalse($collection->contains(new \Ciconia\Common\Text('item1'))); }
/** * @param Text $body * @param Collection $baseTags * * @return Collection */ protected function parseBody(Text $body, Collection $baseTags) { $rows = new Collection(); $body->split('/\\n/')->each(function (Text $row, $index) use($baseTags, &$rows) { $row->trim()->trim('|'); $cells = new Collection(); try { $row->split('/\\|/')->each(function (Text $cell, $index) use(&$baseTags, &$cells) { /* @var Tag $tag */ $tag = clone $baseTags->get($index); $this->markdown->emit('inline', array($cell)); $tag->setText($cell->trim()); $cells->add($tag); }); } catch (\OutOfBoundsException $e) { throw new SyntaxError(sprintf('Too much cells on table body (row #%d).', $index), $this, $row, $this->markdown, $e); } if ($baseTags->count() != $cells->count()) { throw new SyntaxError('Unexpected number of table cells in body.', $this, $row, $this->markdown); } $rows->add($cells); }); return $rows; }