*/ private array $instances = []; public function __construct(private readonly UpstreamSourceRegistry $sources) { } public function forSource(string $source): UpstreamReadOnlyQuery { $key = $this->sources->definition($source)['key']; return $this->instances[$key] ??= new UpstreamReadOnlyQuery($key); } }