From 43d5db56cfc22486b00415079664b5fbc2392b4e Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Thu, 13 Mar 2025 17:14:01 +0100 Subject: [PATCH] Add findSlots method --- composer.json | 3 ++- phpstan.neon | 6 ++++++ src/SlotDbClient.php | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 phpstan.neon diff --git a/composer.json b/composer.json index b1e590a..212c640 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ "psr/http-client": "^1.0" }, "require-dev": { - "guzzlehttp/guzzle": "^7.9" + "guzzlehttp/guzzle": "^7.9", + "phpstan/phpstan": "^2.1" } } diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..a720b54 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + level: 5 + + # Paths to include in the analysis + paths: + - src diff --git a/src/SlotDbClient.php b/src/SlotDbClient.php index 3b87414..a9a9d74 100644 --- a/src/SlotDbClient.php +++ b/src/SlotDbClient.php @@ -48,4 +48,20 @@ class SlotDbClient return $data; } + public function findSlots(array $where = [], array $what = [], int $limit = 250, int $page = 0): array + { + $query = [ + 'limit' => $limit, + 'page' => $page, + 'get' => join(",",$what), + ]; + foreach ($where as $prop=>$cond) { + $whereCond = "{$prop}:{$cond}"; + $query['where[]'] = $whereCond; + } + $res = $this->get("/slots", $query); + $data = json_decode($res->getBody(), true); + return $data; + } + }