refactored code

Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
2025-04-30 03:45:10 +02:00
parent 85702fcb2c
commit 4b23f6ddbb
42 changed files with 1139 additions and 594 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace Anikeen\Id\Resources;
use Anikeen\Id\Concerns\MagicProperties;
use Anikeen\Id\Result;
use JsonSerializable;
abstract class BaseResource implements JsonSerializable
{
use MagicProperties;
public function __construct(protected Result $result)
{
$this->setMagicProperties($this->result->data);
}
/**
* Returns the collection of resources as an array.
*/
public function toArray(): array
{
return (array) $this->result->data;
}
/**
* Returns the collection of resources as a JSON string.
*/
public function jsonSerialize(): array
{
return $this->toArray();
}
}