Total Complexity | 4 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class AddressType extends Type { |
||
10 | public function getSQLDeclaration( array $column, AbstractPlatform $platform ): string { |
||
11 | return 'VARCHAR(10)'; |
||
12 | } |
||
13 | |||
14 | public function convertToPHPValue( mixed $value, AbstractPlatform $platform ): DomainAddressType { |
||
15 | return match ( $value ) { |
||
16 | 'person' => DomainAddressType::Person, |
||
17 | 'company' => DomainAddressType::Company, |
||
18 | default => throw new \InvalidArgumentException( |
||
19 | "Could not convert address type string ({$value}) to enum" |
||
20 | ), |
||
21 | }; |
||
22 | } |
||
23 | |||
24 | public function convertToDatabaseValue( mixed $value, AbstractPlatform $platform ): string { |
||
25 | return match ( $value ) { |
||
26 | DomainAddressType::Person => 'person', |
||
27 | DomainAddressType::Company => 'company', |
||
28 | default => throw new \InvalidArgumentException( |
||
29 | "Could not convert address type enum ({$value}) to string" |
||
30 | ), |
||
31 | }; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @codeCoverageIgnore |
||
36 | * @return string |
||
37 | */ |
||
38 | public function getName(): string { |
||
40 | } |
||
41 | |||
42 | } |
||
43 |