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 TableCell extends AbstractBlock
21{
22    public const TYPE_HEADER = 'header';
23    public const TYPE_DATA   = 'data';
24
25    public const ALIGN_LEFT   = 'left';
26    public const ALIGN_RIGHT  = 'right';
27    public const ALIGN_CENTER = 'center';
28
29    /**
30     * @psalm-var self::TYPE_*
31     * @phpstan-var self::TYPE_*
32     *
33     * @psalm-readonly-allow-private-mutation
34     */
35    private string $type = self::TYPE_DATA;
36
37    /**
38     * @psalm-var self::ALIGN_*|null
39     * @phpstan-var self::ALIGN_*|null
40     *
41     * @psalm-readonly-allow-private-mutation
42     */
43    private ?string $align = null;
44
45    /**
46     * @psalm-param self::TYPE_* $type
47     * @psalm-param self::ALIGN_*|null $align
48     *
49     * @phpstan-param self::TYPE_* $type
50     * @phpstan-param self::ALIGN_*|null $align
51     */
52    public function __construct(string $type = self::TYPE_DATA, ?string $align = null)
53    {
54        parent::__construct();
55
56        $this->type  = $type;
57        $this->align = $align;
58    }
59
60    /**
61     * @psalm-return self::TYPE_*
62     *
63     * @phpstan-return self::TYPE_*
64     */
65    public function getType(): string
66    {
67        return $this->type;
68    }
69
70    /**
71     * @psalm-param self::TYPE_* $type
72     *
73     * @phpstan-param self::TYPE_* $type
74     */
75    public function setType(string $type): void
76    {
77        $this->type = $type;
78    }
79
80    /**
81     * @psalm-return self::ALIGN_*|null
82     *
83     * @phpstan-return self::ALIGN_*|null
84     */
85    public function getAlign(): ?string
86    {
87        return $this->align;
88    }
89
90    /**
91     * @psalm-param self::ALIGN_*|null $align
92     *
93     * @phpstan-param self::ALIGN_*|null $align
94     */
95    public function setAlign(?string $align): void
96    {
97        $this->align = $align;
98    }
99}
100