| Total Complexity | 5 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Coverage | 68.42% |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 14 | trait LabelFieldTrait |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | private $label; |
||
| 20 | |||
| 21 | 1 | protected static function metaForLabel(ClassMetadataBuilder $builder): void |
|
| 22 | { |
||
| 23 | 1 | $builder->createField(LabelFieldInterface::PROP_LABEL, Type::STRING) |
|
| 24 | 1 | ->nullable(true) |
|
| 25 | 1 | ->length(255) |
|
| 26 | 1 | ->build(); |
|
| 27 | 1 | } |
|
| 28 | |||
| 29 | /** |
||
| 30 | * @param ValidatorClassMetaData $metadata |
||
| 31 | * |
||
| 32 | * @throws \Symfony\Component\Validator\Exception\MissingOptionsException |
||
| 33 | * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException |
||
| 34 | * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException |
||
| 35 | */ |
||
| 36 | protected static function validatorMetaForLabel(ValidatorClassMetaData $metadata): void |
||
| 37 | { |
||
| 38 | $metadata->addPropertyConstraints( |
||
| 39 | LabelFieldInterface::PROP_LABEL, |
||
| 40 | [ |
||
| 41 | new Length([ |
||
| 42 | 'min' => 2, |
||
| 43 | 'max' => 255, |
||
| 44 | ]), |
||
| 45 | ] |
||
| 46 | ); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Get label |
||
| 51 | * |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | 2 | public function getLabel(): ?string |
|
| 55 | { |
||
| 56 | 2 | return $this->label; |
|
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Set label |
||
| 61 | * |
||
| 62 | * @param string $label |
||
| 63 | * |
||
| 64 | * @return $this |
||
| 65 | */ |
||
| 66 | 2 | public function setLabel(?string $label): self |
|
| 74 | } |
||
| 75 | } |
||
| 76 |