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\Node\Block\AbstractBlock;
19
20final class TableSection extends AbstractBlock
21{
22    public const TYPE_HEAD = 'head';
23    public const TYPE_BODY = 'body';
24
25    /**
26     * @psalm-var self::TYPE_*
27     * @phpstan-var self::TYPE_*
28     *
29     * @psalm-readonly
30     */
31    private string $type;
32
33    /**
34     * @psalm-param self::TYPE_* $type
35     *
36     * @phpstan-param self::TYPE_* $type
37     */
38    public function __construct(string $type = self::TYPE_BODY)
39    {
40        parent::__construct();
41
42        $this->type = $type;
43    }
44
45    /**
46     * @psalm-return self::TYPE_*
47     *
48     * @phpstan-return self::TYPE_*
49     */
50    public function getType(): string
51    {
52        return $this->type;
53    }
54
55    public function isHead(): bool
56    {
57        return $this->type === self::TYPE_HEAD;
58    }
59
60    public function isBody(): bool
61    {
62        return $this->type === self::TYPE_BODY;
63    }
64}
65