fix: delete dead code

This commit is contained in:
Victor Westerlund 2024-09-27 11:44:20 +02:00
parent 0483e092dd
commit c3c44a5a77
2 changed files with 0 additions and 131 deletions

View file

@ -1,57 +0,0 @@
<?php
namespace VLW\Entities;
use Vegvisir\Path;
use Reflect\Response;
use VLW\Client\API;
use VLW\API\Endpoints;
require_once Path::root("src/client/API.php");
require_once Path::root("api/src/Endpoints.php");
interface EntityInterface {}
abstract class Entity implements EntityInterface {
public const ENTITY_ID = "id";
public readonly ?string $id;
public readonly object $entity;
public readonly Response $response;
protected readonly Api $api;
protected readonly Endpoints $endpoint;
public function __construct(Endpoints $endpoint, ?string $id) {
$this->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() : [];
}
}

View file

@ -1,74 +0,0 @@
<?php
namespace VLW\Entities\Work;
use Vegvisir\Path;
require_once Path::root("src/entities/Entity.php");
class WorkEntity extends Entity {
private array $individuals = [];
private array $signatures = [];
private array $documents = [];
private array $studies = [];
private array $notes = [];
public function __construct(string $id) {
parent::__construct(Endpoints::WORK, $id);
}
public function signatures(): array {
if ($this->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;
}
}