safeGet($entity, 'getTelephones'); $categories = $this->safeGet($entity, 'getCategories'); return [ 'id' => $entity->getId(), 'name' => $this->safeGet($entity, 'getName'), 'email' => $this->safeGet($entity, 'getEmail'), 'telephones' => $telephones instanceof Collection ? array_values(array_map( static fn (ConstructeurTelephone $t): array => ['numero' => $t->getNumero(), 'label' => $t->getLabel()], $telephones->toArray(), )) : [], 'categories' => $categories instanceof Collection ? array_values(array_filter(array_map( static fn (ConstructeurCategorie $c): ?string => $c->getName(), $categories->toArray(), ))) : [], ]; } }