Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ColumnsHandler | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| apply | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| properties | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Field\Schema; |
| 6 | |
| 7 | use Cosray\Exception\RuntimeException; |
| 8 | use Cosray\Field\Capability\Blocks\Resizable; |
| 9 | use Cosray\Field\Field; |
| 10 | |
| 11 | class ColumnsHandler extends Handler |
| 12 | { |
| 13 | public function apply(object $meta, Field $field): void |
| 14 | { |
| 15 | if ($field instanceof Resizable) { |
| 16 | $field->columns($meta->columns, $meta->min, $meta->responsive); |
| 17 | |
| 18 | return; |
| 19 | } |
| 20 | |
| 21 | throw new RuntimeException($this->capabilityErrorMessage($field, Resizable::class)); |
| 22 | } |
| 23 | |
| 24 | public function properties(object $meta, Field $field): array |
| 25 | { |
| 26 | if ($field instanceof Resizable) { |
| 27 | return [ |
| 28 | 'columns' => $field->getColumns(), |
| 29 | 'min' => $field->getMin(), |
| 30 | 'responsive' => $field->getResponsive()->value, |
| 31 | ]; |
| 32 | } |
| 33 | |
| 34 | return []; |
| 35 | } |
| 36 | } |