21 lines
491 B
PHP
21 lines
491 B
PHP
<?php
|
|
|
|
namespace Modules\EcommerceFinance\Services;
|
|
|
|
class UpstreamReadOnlyQueryFactory
|
|
{
|
|
/** @var array<string,UpstreamReadOnlyQuery> */
|
|
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);
|
|
}
|
|
}
|