Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
88.89% |
16 / 18 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| GroupOlxPropertyType | |
88.89% |
16 / 18 |
|
50.00% |
1 / 2 |
15.31 | |
0.00% |
0 / 1 |
| usageType | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| tryFromInternal | |
86.67% |
13 / 15 |
|
0.00% |
0 / 1 |
13.40 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Publishing\Connectors\GroupOlx\Domain\Enums; |
| 6 | |
| 7 | /** |
| 8 | * PropertyType oficial VRSync (Grupo OLX). |
| 9 | * |
| 10 | * @see https://developers.grupozap.com/feeds/vrsync/elements/details.html |
| 11 | */ |
| 12 | enum GroupOlxPropertyType: string |
| 13 | { |
| 14 | case ResidentialApartment = 'Residential / Apartment'; |
| 15 | case ResidentialHome = 'Residential / Home'; |
| 16 | case ResidentialCondo = 'Residential / Condo'; |
| 17 | case ResidentialPenthouse = 'Residential / Penthouse'; |
| 18 | case ResidentialKitnet = 'Residential / Kitnet'; |
| 19 | case ResidentialStudio = 'Residential / Studio'; |
| 20 | case ResidentialLandLot = 'Residential / Land Lot'; |
| 21 | case ResidentialAgricultural = 'Residential / Agricultural'; |
| 22 | case CommercialBusiness = 'Commercial / Business'; |
| 23 | case CommercialOffice = 'Commercial / Office'; |
| 24 | case CommercialBuilding = 'Commercial / Building'; |
| 25 | |
| 26 | public function usageType(): string |
| 27 | { |
| 28 | return str_starts_with($this->value, 'Commercial') |
| 29 | ? 'Commercial' |
| 30 | : 'Residential'; |
| 31 | } |
| 32 | |
| 33 | public static function tryFromInternal(string $type): ?self |
| 34 | { |
| 35 | $normalized = mb_strtolower(trim($type)); |
| 36 | |
| 37 | return match ($normalized) { |
| 38 | 'apartamento', 'apartment', 'residential / apartment' => self::ResidentialApartment, |
| 39 | 'casa', 'home', 'house', 'residential / home' => self::ResidentialHome, |
| 40 | 'casa em condomínio', 'casa em condominio', 'casa_condominio', 'condo', 'residential / condo' => self::ResidentialCondo, |
| 41 | 'cobertura', 'penthouse', 'residential / penthouse' => self::ResidentialPenthouse, |
| 42 | 'kitnet', 'residential / kitnet' => self::ResidentialKitnet, |
| 43 | 'studio', 'residential / studio' => self::ResidentialStudio, |
| 44 | 'terreno', 'land', 'land lot', 'residential / land lot' => self::ResidentialLandLot, |
| 45 | 'sítio / fazenda', 'sitio / fazenda', 'sitio_fazenda', 'fazenda', 'sítio', 'sitio', 'agricultural', 'residential / agricultural' => self::ResidentialAgricultural, |
| 46 | 'comercial', 'business', 'commercial / business' => self::CommercialBusiness, |
| 47 | 'sala', 'escritório', 'escritorio', 'office', 'commercial / office' => self::CommercialOffice, |
| 48 | 'prédio', 'predio', 'building', 'commercial / building' => self::CommercialBuilding, |
| 49 | default => self::tryFrom(trim($type)), |
| 50 | }; |
| 51 | } |
| 52 | } |