Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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 string $value;
22
    private array $options = [
23
        'rowspan' => 1,
24
        'colspan' => 1,
25
        'style' => null,
26
    ];
27
 
28
    public function __construct(string $value = '', array $options = [])
29
    {
30
        $this->value = $value;
31
 
32
        // check option names
33
        if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
34
            throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
35
        }
36
 
37
        if (isset($options['style']) && !$options['style'] instanceof TableCellStyle) {
38
            throw new InvalidArgumentException('The style option must be an instance of "TableCellStyle".');
39
        }
40
 
41
        $this->options = array_merge($this->options, $options);
42
    }
43
 
44
    /**
45
     * Returns the cell value.
46
     */
47
    public function __toString(): string
48
    {
49
        return $this->value;
50
    }
51
 
52
    /**
53
     * Gets number of colspan.
54
     */
55
    public function getColspan(): int
56
    {
57
        return (int) $this->options['colspan'];
58
    }
59
 
60
    /**
61
     * Gets number of rowspan.
62
     */
63
    public function getRowspan(): int
64
    {
65
        return (int) $this->options['rowspan'];
66
    }
67
 
68
    public function getStyle(): ?TableCellStyle
69
    {
70
        return $this->options['style'];
71
    }
72
}