diff options
Diffstat (limited to 'vendor/symfony/console/Helper/TableCell.php')
-rw-r--r-- | vendor/symfony/console/Helper/TableCell.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/vendor/symfony/console/Helper/TableCell.php b/vendor/symfony/console/Helper/TableCell.php new file mode 100644 index 0000000..1c4eeea --- /dev/null +++ b/vendor/symfony/console/Helper/TableCell.php | |||
@@ -0,0 +1,71 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Console\Helper; | ||
13 | |||
14 | use Symfony\Component\Console\Exception\InvalidArgumentException; | ||
15 | |||
16 | /** | ||
17 | * @author Abdellatif Ait boudad <a.aitboudad@gmail.com> | ||
18 | */ | ||
19 | class TableCell | ||
20 | { | ||
21 | private array $options = [ | ||
22 | 'rowspan' => 1, | ||
23 | 'colspan' => 1, | ||
24 | 'style' => null, | ||
25 | ]; | ||
26 | |||
27 | public function __construct( | ||
28 | private string $value = '', | ||
29 | array $options = [], | ||
30 | ) { | ||
31 | // check option names | ||
32 | if ($diff = array_diff(array_keys($options), array_keys($this->options))) { | ||
33 | throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff))); | ||
34 | } | ||
35 | |||
36 | if (isset($options['style']) && !$options['style'] instanceof TableCellStyle) { | ||
37 | throw new InvalidArgumentException('The style option must be an instance of "TableCellStyle".'); | ||
38 | } | ||
39 | |||
40 | $this->options = array_merge($this->options, $options); | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * Returns the cell value. | ||
45 | */ | ||
46 | public function __toString(): string | ||
47 | { | ||
48 | return $this->value; | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * Gets number of colspan. | ||
53 | */ | ||
54 | public function getColspan(): int | ||
55 | { | ||
56 | return (int) $this->options['colspan']; | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * Gets number of rowspan. | ||
61 | */ | ||
62 | public function getRowspan(): int | ||
63 | { | ||
64 | return (int) $this->options['rowspan']; | ||
65 | } | ||
66 | |||
67 | public function getStyle(): ?TableCellStyle | ||
68 | { | ||
69 | return $this->options['style']; | ||
70 | } | ||
71 | } | ||