diff --git a/src/Components/Blocks/Reference.php b/src/Components/Blocks/Reference.php index ef0a560..6570de1 100644 --- a/src/Components/Blocks/Reference.php +++ b/src/Components/Blocks/Reference.php @@ -43,9 +43,7 @@ final class Reference implements StateUpdatingBlock 'title' => isset($matches[3]) ? $matches[3] : null, ]; - $State = $State->setting( - $State->get(DefinitionBook::class)->setting($id, $Data) - ); + $State->get(DefinitionBook::class)->mutatingSet($id, $Data); return new self($State); } diff --git a/src/Configurables/DefinitionBook.php b/src/Configurables/DefinitionBook.php index 0c22538..38e55b0 100644 --- a/src/Configurables/DefinitionBook.php +++ b/src/Configurables/DefinitionBook.php @@ -2,12 +2,12 @@ namespace Erusev\Parsedown\Configurables; -use Erusev\Parsedown\Configurable; +use Erusev\Parsedown\MutableConfigurable; /** * @psalm-type _Data=array{url: string, title: string|null} */ -final class DefinitionBook implements Configurable +final class DefinitionBook implements MutableConfigurable { /** @var array */ private $book; @@ -29,14 +29,10 @@ final class DefinitionBook implements Configurable /** * @param string $id * @param _Data $data - * @return self */ - public function setting($id, array $data) + public function mutatingSet($id, array $data): void { - $book = $this->book; - $book[$id] = $data; - - return new self($book); + $this->book[$id] = $data; } /** @@ -51,4 +47,9 @@ final class DefinitionBook implements Configurable return null; } + + public function isolatedCopy(): self + { + return new self($this->book); + } }