'cep_nao_encontrado', 'mensagem' => 'no route registered']); return true; } $calls = array_filter(explode("\n", (string) file_get_contents($state . '/calls.log')), 'strlen'); $seen = count(array_filter($calls, static fn (string $line): bool => $line === $uri)); $spec = $specs[min(max($seen - 1, 0), count($specs) - 1)]; if (($spec['kind'] ?? 'static') === 'csv_echo') { parse_str((string) parse_url($uri, PHP_URL_QUERY), $query); $ceps = array_filter(explode(',', (string) ($query['ceps'] ?? '')), 'strlen'); $rows = ['cep,logradouro,complemento,unidade,bairro,localidade,uf,estado,regiao,ibge,gia,ddd,siafi']; foreach ($ceps as $cep) { $rows[] = $cep . ',Rua Teste,,,Centro,Cidade,SP,São Paulo,Sudeste,1,,11,1'; } header('Content-Type: text/csv; charset=utf-8'); http_response_code(200); echo implode("\n", $rows) . "\n"; return true; } foreach (($spec['headers'] ?? []) as $name => $value) { header($name . ': ' . $value); } header('Content-Type: ' . ($spec['content_type'] ?? 'text/plain; charset=utf-8')); http_response_code((int) ($spec['status'] ?? 200)); echo (string) ($spec['body'] ?? ''); return true;