Add removeMetadata to StateInterface.

This commit is contained in:
arabcoders
2025-05-09 22:47:52 +03:00
parent 3bc94cff93
commit 61d6584fd5
2 changed files with 25 additions and 0 deletions

View File

@@ -459,6 +459,22 @@ final class StateEntity implements iState
return $this->metadata[$via] ?? [];
}
/**
* @inheritdoc
*/
public function removeMetadata(string $backend): array
{
if (null === ($this->metadata[$backend] ?? null)) {
return [];
}
$metadata = $this->metadata[$backend];
unset($this->metadata[$backend]);
return $metadata;
}
/**
* @inheritdoc
*/

View File

@@ -295,6 +295,15 @@ interface StateInterface extends LoggerAwareInterface
*/
public function getMetadata(string|null $via = null): array;
/**
* Get metadata.
*
* @param string $backend The backend name to remove metadata from.
*
* @return array Return the removed metadata. Or empty array if not found.
*/
public function removeMetadata(string $backend): array;
/**
* Set metadata related to {$this->via} backend.
*