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