1<?php
2
3declare(strict_types=1);
4
5/*
6 * This is part of the league/commonmark package.
7 *
8 * (c) Martin Hasoň <martin.hason@gmail.com>
9 * (c) Webuni s.r.o. <info@webuni.cz>
10 * (c) Colin O'Dell <colinodell@gmail.com>
11 *
12 * For the full copyright and license information, please view the LICENSE
13 * file that was distributed with this source code.
14 */
15
16namespace League\CommonMark\Extension\Table;
17
18use League\CommonMark\Block\Element\AbstractBlock;
19use League\CommonMark\Block\Element\AbstractStringContainerBlock;
20use League\CommonMark\Block\Element\InlineContainerInterface;
21use League\CommonMark\ContextInterface;
22use League\CommonMark\Cursor;
23
24final class TableSection extends AbstractStringContainerBlock implements InlineContainerInterface
25{
26    const TYPE_HEAD = 'thead';
27    const TYPE_BODY = 'tbody';
28
29    /** @var string */
30    public $type = self::TYPE_BODY;
31
32    public function __construct(string $type = self::TYPE_BODY)
33    {
34        parent::__construct();
35        $this->type = $type;
36    }
37
38    public function isHead(): bool
39    {
40        return self::TYPE_HEAD === $this->type;
41    }
42
43    public function isBody(): bool
44    {
45        return self::TYPE_BODY === $this->type;
46    }
47
48    public function canContain(AbstractBlock $block): bool
49    {
50        return $block instanceof TableRow;
51    }
52
53    public function isCode(): bool
54    {
55        return false;
56    }
57
58    public function matchesNextLine(Cursor $cursor): bool
59    {
60        return false;
61    }
62
63    public function handleRemainingContents(ContextInterface $context, Cursor $cursor): void
64    {
65    }
66}
67