refactor: entity move and delete
All checks were successful
Build Test / build (pull_request) Successful in 18s
JS Unit Tests / test (pull_request) Successful in 16s
PHP Unit Tests / test (pull_request) Successful in 41s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-05-07 23:58:36 -04:00
parent cce65c3e62
commit 69d6c7fd1a
5 changed files with 40 additions and 5 deletions

View File

@@ -35,6 +35,10 @@ class ResourceIdentifier implements ResourceIdentifierInterface {
return $this->provider;
}
public function jsonSerialize(): string {
return (string) $this;
}
/**
* Parse a colon-separated identifier string and return the appropriate level class
*

View File

@@ -9,10 +9,12 @@ declare(strict_types=1);
namespace KTXF\Resource\Identifier;
use KTXF\Json\JsonSerializable;
/**
* Top-level identifier for resources (provider level)
*/
interface ResourceIdentifierInterface extends \Stringable {
interface ResourceIdentifierInterface extends JsonSerializable, \Stringable {
/** The provider segment (e.g. "imap") */
public function provider(): string;
@@ -23,4 +25,7 @@ interface ResourceIdentifierInterface extends \Stringable {
/** Canonical string form: provider[:service[:collection[:entity]]] */
public function __toString(): string;
/** Canonical JSON form: provider[:service[:collection[:entity]]] */
public function jsonSerialize(): string;
}

View File

@@ -151,4 +151,11 @@ class ResourceIdentifiers implements ResourceIdentifiersInterface {
return count($this->identifiers) === 0;
}
public function jsonSerialize(): array {
return array_map(
static fn (ResourceIdentifierInterface $identifier): string => $identifier->jsonSerialize(),
$this->identifiers,
);
}
}

View File

@@ -9,10 +9,12 @@ declare(strict_types=1);
namespace KTXF\Resource\Identifier;
use KTXF\Json\JsonSerializable;
/**
* A typed collection of resource identifiers with search and filter capabilities
*/
interface ResourceIdentifiersInterface extends \Countable, \IteratorAggregate {
interface ResourceIdentifiersInterface extends JsonSerializable, \Countable, \IteratorAggregate {
/** Add an identifier to the collection */
public function add(ResourceIdentifierInterface $identifier): void;
@@ -47,4 +49,7 @@ interface ResourceIdentifiersInterface extends \Countable, \IteratorAggregate {
/** Get unique entity names */
public function entities(): array;
/** Serialize as an array of canonical identifier strings */
public function jsonSerialize(): array;
}