From 6dad22f226ce594df05e112e2fe9e8d9db63f419 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Fri, 27 Sep 2024 09:48:37 +0000 Subject: [PATCH] fix: delete old, unused database class (#3) A relic from the past which was never used. Reviewed-on: https://codeberg.org/vlw/vlw.se/pulls/3 Co-authored-by: Victor Westerlund Co-committed-by: Victor Westerlund --- src/entities/Entity.php | 57 ------------------------------ src/entities/VLW/Work.php | 74 --------------------------------------- 2 files changed, 131 deletions(-) delete mode 100644 src/entities/Entity.php delete mode 100644 src/entities/VLW/Work.php diff --git a/src/entities/Entity.php b/src/entities/Entity.php deleted file mode 100644 index 243fff2..0000000 --- a/src/entities/Entity.php +++ /dev/null @@ -1,57 +0,0 @@ -id = $id; - $this->api = new Api(); - $this->endpoint = $endpoint; - - $this->resolve_entity_by_id(); - } - - private function resolve_entity_by_id() { - // Bail out wit a dummy Response if no id was provided - if (!$this->id) { - $this->response = new Response("", 404); - return; - } - - $this->response = $this->api - ->call($this->endpoint->value) - ->params([self::ENTITY_ID => $this->id]) - ->get(); - - // Load response into entity object if successful - if ($this->response->ok) { - $this->entity = (object) $this->response->json()[0]; - } - } - - public function resolve(Endpoints $endpoint, array $params): array { - $response = $this->api->call($endpoint->value)->params($params)->get(); - - return $response->ok ? $response->json() : []; - } - } \ No newline at end of file diff --git a/src/entities/VLW/Work.php b/src/entities/VLW/Work.php deleted file mode 100644 index 5b4b26a..0000000 --- a/src/entities/VLW/Work.php +++ /dev/null @@ -1,74 +0,0 @@ -signatures) { - return $this->signatures; - } - - foreach ($this->resolve(Endpoints::ICELDB_ANALYSES_SIGNATURES, ["ref_analysis_id" => $this->id]) as $rel) { - $this->signatures[$rel["id"]] = $rel; - $this->signatures[$rel["id"]]["user"] = $this->resolve(Endpoints::ICELDB_USERS, ["ref_user_id" => $rel["ref_user_id"]])[0]; - } - - return $this->signatures; - } - - public function documents(): array { - if ($this->documents) { - return $this->documents; - } - - $this->documents = $this->resolve(Endpoints::ICELDB_ANALYSES_DOCUMENTS, ["ref_analysis_id" => $this->id]); - return $this->documents; - } - - public function studies(): array { - if ($this->studies) { - return $this->studies; - } - - foreach ($this->resolve(Endpoints::ICELDB_STUDIES_ANALYSES, ["ref_analysis_id" => $this->id]) as $rel) { - $this->studies[] = $this->resolve(Endpoints::ICELDB_STUDIES, ["id" => $rel["ref_study_id"]]); - } - - return $this->studies; - } - - public function notes(): array { - if ($this->notes) { - return $this->notes; - } - - $this->notes = $this->resolve(Endpoints::ICELDB_ANALYSES_NOTES, ["ref_analysis_id" => $this->id]); - return $this->notes; - } - - public function individuals(): array { - if ($this->individuals) { - return $this->individuals; - } - - foreach ($this->resolve(Endpoints::ICELDB_ANALYSES_INDIVIDUALS, ["ref_analysis_id" => $this->id]) as $rel) { - $this->individuals[] = $this->resolve(Endpoints::ICELDB_INDIVIDUALS, ["id" => $rel["ref_individual_id"]])[0]; - } - - return $this->individuals; - } - } \ No newline at end of file