| Total Complexity | 5 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | trait BaseCatalogTrait |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var Repository|null |
||
| 14 | * @internal |
||
| 15 | */ |
||
| 16 | private $repository; |
||
| 17 | |||
| 18 | 124 | public function withRepository(Repository $repository): void |
|
| 19 | { |
||
| 20 | 124 | if ($repository === $this->repository) { |
|
| 21 | 1 | return; |
|
| 22 | } |
||
| 23 | |||
| 24 | 124 | if (null !== $this->repository) { |
|
| 25 | 1 | throw new LogicException( |
|
| 26 | 1 | sprintf('This instance of %s already contains a repository', get_class($this)), |
|
| 27 | 1 | ); |
|
| 28 | } |
||
| 29 | |||
| 30 | 124 | $this->repository = $repository; |
|
| 31 | } |
||
| 32 | |||
| 33 | 119 | public function repository(): Repository |
|
| 42 | } |
||
| 43 | } |
||
| 44 |