Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
71.43% covered (warning)
71.43%
5 / 7
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
WidthHandler
71.43% covered (warning)
71.43%
5 / 7
0.00% covered (danger)
0.00%
0 / 2
4.37
0.00% covered (danger)
0.00%
0 / 1
 apply
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
2.06
 properties
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
2.15
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray\Field\Schema;
6
7use Cosray\Exception\RuntimeException;
8use Cosray\Field\Capability\Resizable;
9use Cosray\Field\Field;
10
11class WidthHandler extends Handler
12{
13    public function apply(object $meta, Field $field): void
14    {
15        if ($field instanceof Resizable) {
16            $field->width($meta->width);
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 ['width' => $field->getWidth()];
28        }
29
30        return [];
31    }
32}