src/Infra/Services/PropertiesService.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types 1);
  3. namespace App\Infra\Services;
  4. use App\Infra\Services\ApiService;
  5. use App\Infra\Services\FilterApiService;
  6. class PropertiesService
  7. {
  8.     private $apiService ;
  9.     private $filterApiService;
  10.     
  11.     public function __construct(ApiService $apiServiceFilterApiService $filterApiService)
  12.     {
  13.         $this->apiService $apiService;
  14.         $this->filterApiService $filterApiService;
  15.     }
  16.     public function getTypesProperties()
  17.     {
  18.         $availablesTypes = [];
  19.         $properties $this->apiService->getAllProperties();
  20.         $allTypes $this->filterApiService->arrayAllTypes();
  21.         foreach ($properties['properties'] as $property) {
  22.             foreach ($allTypes as $name => $type) {
  23.                 if ($property[$type['status']] == $type['id'] && $type['id']) {
  24.                     if (!in_array($name$availablesTypes) && $property['construction']['construction_step'] !== '3') {
  25.                         $availablesTypes[] = $name;
  26.                     }
  27.                 }
  28.             }
  29.         }
  30.         return $availablesTypes;
  31.     }
  32. }