<?php
declare(strict_types = 1);
namespace App\Infra\Services;
use App\Infra\Services\ApiService;
use App\Infra\Services\FilterApiService;
class PropertiesService
{
private $apiService ;
private $filterApiService;
public function __construct(ApiService $apiService, FilterApiService $filterApiService)
{
$this->apiService = $apiService;
$this->filterApiService = $filterApiService;
}
public function getTypesProperties()
{
$availablesTypes = [];
$properties = $this->apiService->getAllProperties();
$allTypes = $this->filterApiService->arrayAllTypes();
foreach ($properties['properties'] as $property) {
foreach ($allTypes as $name => $type) {
if ($property[$type['status']] == $type['id'] && $type['id']) {
if (!in_array($name, $availablesTypes) && $property['construction']['construction_step'] !== '3') {
$availablesTypes[] = $name;
}
}
}
}
return $availablesTypes;
}
}