Skip to content

Commit

Permalink
pool mapper getter
Browse files Browse the repository at this point in the history
  • Loading branch information
nekufa committed May 8, 2024
1 parent 32c09e5 commit 1d6f791
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,19 @@ public function getChanges(): array
return $changes;
}

public function getSpace(string $name): Space
public function getMapper(string $name): Mapper
{
[$mapper, $space] = explode('.', $name);
if (!array_key_exists($mapper, $this->mappers)) {
if (!array_key_exists($name, $this->mappers)) {
$callback = $this->callback;
$this->mappers[$mapper] = $callback($mapper);
$this->mappers[$name] = $callback($name);
}
return $this->mappers[$mapper]->getSpace($space);

return $this->mappers[$name];
}

public function getSpace(string $name): Space
{
[$mapper, $space] = explode('.', $name);
return $this->getMapper($mapper)->getSpace($space);
}
}

0 comments on commit 1d6f791

Please sign in to comment.