Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
77.78% |
7 / 9 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| IsResizable | |
77.78% |
7 / 9 |
|
66.67% |
2 / 3 |
7.54 | |
0.00% |
0 / 1 |
| columns | |
71.43% |
5 / 7 |
|
0.00% |
0 / 1 |
5.58 | |||
| getColumns | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getMinCellWidth | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Field\Capability\Blocks; |
| 6 | |
| 7 | use ValueError; |
| 8 | |
| 9 | trait IsResizable |
| 10 | { |
| 11 | protected int $columns = 12; |
| 12 | protected int $minCellWidth = 1; |
| 13 | |
| 14 | public function columns(int $columns, int $minCellWidth = 1): static |
| 15 | { |
| 16 | if ($columns < 1 || $columns > 25) { |
| 17 | throw new ValueError('The value of $columns must be >= 1 and <= 25'); |
| 18 | } |
| 19 | |
| 20 | if ($minCellWidth < 1 || $minCellWidth > $columns) { |
| 21 | throw new ValueError('The value of $minCellWidth must be >= 1 and <= ' . (string) $columns); |
| 22 | } |
| 23 | |
| 24 | $this->columns = $columns; |
| 25 | $this->minCellWidth = $minCellWidth; |
| 26 | |
| 27 | return $this; |
| 28 | } |
| 29 | |
| 30 | public function getColumns(): int |
| 31 | { |
| 32 | return $this->columns; |
| 33 | } |
| 34 | |
| 35 | public function getMinCellWidth(): int |
| 36 | { |
| 37 | return $this->minCellWidth; |
| 38 | } |
| 39 | } |