Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/console/Helper/TableCell.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 1fec387a4317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
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 /** | |
22 * @var string | |
23 */ | |
24 private $value; | |
25 | |
26 /** | |
27 * @var array | |
28 */ | |
29 private $options = array( | |
30 'rowspan' => 1, | |
31 'colspan' => 1, | |
32 ); | |
33 | |
34 /** | |
35 * @param string $value | |
36 * @param array $options | |
37 */ | |
38 public function __construct($value = '', array $options = array()) | |
39 { | |
40 if (is_numeric($value) && !is_string($value)) { | |
41 $value = (string) $value; | |
42 } | |
43 | |
44 $this->value = $value; | |
45 | |
46 // check option names | |
47 if ($diff = array_diff(array_keys($options), array_keys($this->options))) { | |
48 throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff))); | |
49 } | |
50 | |
51 $this->options = array_merge($this->options, $options); | |
52 } | |
53 | |
54 /** | |
55 * Returns the cell value. | |
56 * | |
57 * @return string | |
58 */ | |
59 public function __toString() | |
60 { | |
61 return $this->value; | |
62 } | |
63 | |
64 /** | |
65 * Gets number of colspan. | |
66 * | |
67 * @return int | |
68 */ | |
69 public function getColspan() | |
70 { | |
71 return (int) $this->options['colspan']; | |
72 } | |
73 | |
74 /** | |
75 * Gets number of rowspan. | |
76 * | |
77 * @return int | |
78 */ | |
79 public function getRowspan() | |
80 { | |
81 return (int) $this->options['rowspan']; | |
82 } | |
83 } |