Total Complexity | 5 |
Total Lines | 75 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
13 | trait CountryCodeFieldTrait |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var string|null |
||
18 | */ |
||
19 | private $countryCode; |
||
20 | |||
21 | /** |
||
22 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
23 | */ |
||
24 | public static function metaForCountryCode(ClassMetadataBuilder $builder): void |
||
25 | { |
||
26 | $fieldBuilder = new FieldBuilder( |
||
27 | $builder, |
||
28 | [ |
||
29 | 'fieldName' => CountryCodeFieldInterface::PROP_COUNTRY_CODE, |
||
30 | 'type' => Type::STRING, |
||
31 | 'default' => CountryCodeFieldInterface::DEFAULT_COUNTRY_CODE, |
||
32 | ] |
||
33 | ); |
||
34 | $fieldBuilder |
||
35 | ->columnName(MappingHelper::getColumnNameForField(CountryCodeFieldInterface::PROP_COUNTRY_CODE)) |
||
36 | ->nullable(true) |
||
37 | ->unique(false) |
||
38 | ->length(6) |
||
39 | ->build(); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * This method sets the validation for this field. |
||
44 | * |
||
45 | * You should add in as many relevant property constraints as you see fit. |
||
46 | * |
||
47 | * @see https://symfony.com/doc/current/validation.html#supported-constraints |
||
48 | * |
||
49 | * @param ValidatorClassMetaData $metadata |
||
50 | * |
||
51 | * @throws \Symfony\Component\Validator\Exception\MissingOptionsException |
||
52 | * @throws \Symfony\Component\Validator\Exception\InvalidOptionsException |
||
53 | * @throws \Symfony\Component\Validator\Exception\ConstraintDefinitionException |
||
54 | */ |
||
55 | protected static function validatorMetaForPropertyCountryCode(ValidatorClassMetaData $metadata): void |
||
60 | ); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @return string|null |
||
65 | */ |
||
66 | public function getCountryCode(): ?string |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * @param string|null $countryCode |
||
77 | * |
||
78 | * @return self |
||
79 | */ |
||
80 | private function setCountryCode(?string $countryCode): self |
||
90 |