Phosphorum\Markdown\TableExtension::parseHeader PHP Method

parseHeader() protected method

protected parseHeader ( Ciconia\Common\Text $header, Ciconia\Common\Collection $baseTags ) : Ciconia\Common\Collection
$header Ciconia\Common\Text
$baseTags Ciconia\Common\Collection
return Ciconia\Common\Collection
    protected function parseHeader(Text $header, Collection $baseTags)
    {
        $cells = new Collection();
        try {
            $header->split('/\\|/')->each(function (Text $cell, $index) use($baseTags, &$cells) {
                /* @var Tag $tag */
                $tag = clone $baseTags->get($index);
                $tag->setName('th');
                $this->markdown->emit('inline', [$cell]);
                $tag->setText($cell->trim());
                $cells->add($tag);
            });
        } catch (\OutOfBoundsException $e) {
            throw new SyntaxError('Too much cells on table header.', $this, $header, $this->markdown, $e);
        }
        if ($baseTags->count() != $cells->count()) {
            throw new SyntaxError('Unexpected number of table cells in header.', $this, $header, $this->markdown);
        }
        return $cells;
    }