Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| TitleHandler | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| resolve | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Node\Schema; |
| 6 | |
| 7 | use Cosray\Exception\RuntimeException; |
| 8 | |
| 9 | class TitleHandler extends Handler |
| 10 | { |
| 11 | public function resolve(object $meta, string $nodeClass): array |
| 12 | { |
| 13 | if ($meta->field === '') { |
| 14 | throw new RuntimeException( |
| 15 | "The #[Title] attribute on node '{$nodeClass}' requires a non-empty field name when used on a class.", |
| 16 | ); |
| 17 | } |
| 18 | |
| 19 | return ['titleField' => $meta->field]; |
| 20 | } |
| 21 | } |