Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
| Cell | |
100.00% |
12 / 12 |
|
100.00% |
7 / 7 |
7 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| getNode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getRow | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getCol | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getRowSpan | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getColSpan | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isHeader | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | /** |
| 4 | * Pop PHP Framework (https://www.popphp.org/) |
| 5 | * |
| 6 | * @link https://github.com/popphp/popphp-framework |
| 7 | * @author Nick Sagona, III <nick@popphp.org> |
| 8 | * @copyright Copyright (c) 2009-2026 Nick Sagona, III |
| 9 | * @license https://www.popphp.org/license New BSD License |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * @namespace |
| 14 | */ |
| 15 | namespace Pop\Pdf\Build\Html\Table; |
| 16 | |
| 17 | use Pop\Dom\Child; |
| 18 | |
| 19 | /** |
| 20 | * Pdf HTML table cell class |
| 21 | * |
| 22 | * A value object describing one table cell's grid position/span and the DOM |
| 23 | * node its content/attributes come from. |
| 24 | * |
| 25 | * @category Pop |
| 26 | * @package Pop\Pdf |
| 27 | * @author Nick Sagona, III <nick@popphp.org> |
| 28 | * @copyright Copyright (c) 2009-2026 Nick Sagona, III |
| 29 | * @license https://www.popphp.org/license New BSD License |
| 30 | * @version 6.0.0 |
| 31 | */ |
| 32 | class Cell |
| 33 | { |
| 34 | |
| 35 | /** |
| 36 | * The <td>/<th> DOM node |
| 37 | * @var Child |
| 38 | */ |
| 39 | protected Child $node; |
| 40 | |
| 41 | /** |
| 42 | * Zero-based row index this cell starts at |
| 43 | * @var int |
| 44 | */ |
| 45 | protected int $row; |
| 46 | |
| 47 | /** |
| 48 | * Zero-based column index this cell starts at |
| 49 | * @var int |
| 50 | */ |
| 51 | protected int $col; |
| 52 | |
| 53 | /** |
| 54 | * Number of rows this cell spans |
| 55 | * @var int |
| 56 | */ |
| 57 | protected int $rowSpan; |
| 58 | |
| 59 | /** |
| 60 | * Number of columns this cell spans |
| 61 | * @var int |
| 62 | */ |
| 63 | protected int $colSpan; |
| 64 | |
| 65 | /** |
| 66 | * Whether this cell belongs to a header row |
| 67 | * @var bool |
| 68 | */ |
| 69 | protected bool $isHeader; |
| 70 | |
| 71 | /** |
| 72 | * Constructor |
| 73 | * |
| 74 | * Instantiate a table cell. |
| 75 | * |
| 76 | * @param Child $node |
| 77 | * @param int $row |
| 78 | * @param int $col |
| 79 | * @param int $rowSpan |
| 80 | * @param int $colSpan |
| 81 | * @param bool $isHeader |
| 82 | */ |
| 83 | public function __construct(Child $node, int $row, int $col, int $rowSpan = 1, int $colSpan = 1, bool $isHeader = false) |
| 84 | { |
| 85 | // Upper-bounded to the HTML living standard's own caps (rowspan |
| 86 | // 65534, colspan 1000) - an author-provided but unbounded span |
| 87 | // attribute would otherwise let a single cell allocate unbounded |
| 88 | // grid slots/row-height sums. |
| 89 | $this->node = $node; |
| 90 | $this->row = $row; |
| 91 | $this->col = $col; |
| 92 | $this->rowSpan = min(65534, max(1, $rowSpan)); |
| 93 | $this->colSpan = min(1000, max(1, $colSpan)); |
| 94 | $this->isHeader = $isHeader; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Get the cell's DOM node |
| 99 | * |
| 100 | * @return Child |
| 101 | */ |
| 102 | public function getNode(): Child |
| 103 | { |
| 104 | return $this->node; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Get the row this cell starts at |
| 109 | * |
| 110 | * @return int |
| 111 | */ |
| 112 | public function getRow(): int |
| 113 | { |
| 114 | return $this->row; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Get the column this cell starts at |
| 119 | * |
| 120 | * @return int |
| 121 | */ |
| 122 | public function getCol(): int |
| 123 | { |
| 124 | return $this->col; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Get the number of rows this cell spans |
| 129 | * |
| 130 | * @return int |
| 131 | */ |
| 132 | public function getRowSpan(): int |
| 133 | { |
| 134 | return $this->rowSpan; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Get the number of columns this cell spans |
| 139 | * |
| 140 | * @return int |
| 141 | */ |
| 142 | public function getColSpan(): int |
| 143 | { |
| 144 | return $this->colSpan; |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Determine if this cell belongs to a header row |
| 149 | * |
| 150 | * @return bool |
| 151 | */ |
| 152 | public function isHeader(): bool |
| 153 | { |
| 154 | return $this->isHeader; |
| 155 | } |
| 156 | |
| 157 | } |