feat: NetatmoClient with token rotation, OpenMeteoClient, LiveSource, netatmo-init

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
2026-09-11 14:45:54 +02:00
co-authored by Claude Fable 5.1
parent dababbd1f2
commit 4250fa5abf
9 changed files with 551 additions and 6 deletions
+49
View File
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace Weerscherm\Tests;
use Weerscherm\HttpClient;
use Weerscherm\HttpResponse;
/** Testdubbel: geeft geplande responses in volgorde terug en registreert elk request. */
final class FakeHttp implements HttpClient
{
/** @var list<HttpResponse> */
private array $queue = [];
/** @var list<array{method: string, url: string, params: array, headers: array}> */
public array $requests = [];
public function queue(int $status, array|string $body): self
{
$this->queue[] = new HttpResponse($status, is_string($body) ? $body : json_encode($body, JSON_THROW_ON_ERROR));
return $this;
}
public function get(string $url, array $query = [], array $headers = []): HttpResponse
{
return $this->take('GET', $url, $query, $headers);
}
public function postForm(string $url, array $fields): HttpResponse
{
return $this->take('POST', $url, $fields, []);
}
/** @return list<array> */
public function requestsOf(string $method): array
{
return array_values(array_filter($this->requests, fn(array $r) => $r['method'] === $method));
}
private function take(string $method, string $url, array $params, array $headers): HttpResponse
{
$this->requests[] = ['method' => $method, 'url' => $url, 'params' => $params, 'headers' => $headers];
if ($this->queue === []) {
throw new \LogicException("Geen response gepland voor $method $url");
}
return array_shift($this->queue);
}
}