Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
77.78% covered (warning)
77.78%
7 / 9
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
IsResizable
77.78% covered (warning)
77.78%
7 / 9
66.67% covered (warning)
66.67%
2 / 3
7.54
0.00% covered (danger)
0.00%
0 / 1
 columns
71.43% covered (warning)
71.43%
5 / 7
0.00% covered (danger)
0.00%
0 / 1
5.58
 getColumns
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getMinCellWidth
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray\Field\Capability\Blocks;
6
7use ValueError;
8
9trait 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}