*/ class CompositeRepository implements RepositoryInterface { /** * List of repositories * @var RepositoryInterface[] */ private $repositories; /** * Constructor * @param RepositoryInterface[] $repositories */ public function __construct(array $repositories) { $this->repositories = []; foreach ($repositories as $repo) { $this->addRepository($repo); } } public function getRepoName(): string { return 'composite repo ('.implode(', ', array_map(static function ($repo): string { return $repo->getRepoName(); }, $this->repositories)).')'; } /** * Returns all the wrapped repositories * * @return RepositoryInterface[] */ public function getRepositories(): array { return $this->repositories; } /** * @inheritDoc */ public function hasPackage(PackageInterface $package): bool { foreach ($this->repositories as $repository) { /* @var $repository RepositoryInterface */ if ($repository->hasPackage($package)) { return true; } } return false; } /** * @inheritDoc */ public function findPackage($name, $constraint): ?BasePackage { foreach ($this->repositories as $repository) { /* @var $repository RepositoryInterface */ $package = $repository->findPackage($name, $constraint); if (null !== $package) { return $package; } } return null; } /** * @inheritDoc */ public function findPackages($name, $constraint = null): array { $packages = []; foreach ($this->repositories as $repository) { /* @var $repository RepositoryInterface */ $packages[] = $repository->findPackages($name, $constraint); } return $packages ? array_merge(...$packages) : []; } /** * @inheritDoc */ public function loadPackages( array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = [], ): array { $packages = []; $namesFound = []; foreach ($this->repositories as $repository) { /* @var $repository RepositoryInterface */ $result = $repository->loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded); $packages[] = $result['packages']; $namesFound[] = $result['namesFound']; } return [ 'packages' => $packages ? array_merge(...$packages) : [], 'namesFound' => $namesFound ? array_unique(array_merge(...$namesFound)) : [], ]; } /** * @inheritDoc */ public function search(string $query, int $mode = 0, ?string $type = null): array { $matches = []; foreach ($this->repositories as $repository) { /* @var $repository RepositoryInterface */ $matches[] = $repository->search($query, $mode, $type); } return \count($matches) > 0 ? array_merge(...$matches) : []; } /** * @inheritDoc */ public function getPackages(): array { $packages = []; foreach ($this->repositories as $repository) { /* @var $repository RepositoryInterface */ $packages[] = $repository->getPackages(); } return $packages ? array_merge(...$packages) : []; } /** * @inheritDoc */ public function getProviders($packageName): array { $results = []; foreach ($this->repositories as $repository) { /* @var $repository RepositoryInterface */ $results[] = $repository->getProviders($packageName); } return $results ? array_merge(...$results) : []; } public function removePackage(PackageInterface $package): void { foreach ($this->repositories as $repository) { if ($repository instanceof WritableRepositoryInterface) { $repository->removePackage($package); } } } /** * @inheritDoc */ public function count(): int { $total = 0; foreach ($this->repositories as $repository) { /* @var $repository RepositoryInterface */ $total += $repository->count(); } return $total; } /** * Add a repository. */ public function addRepository(RepositoryInterface $repository): void { if ($repository instanceof self) { foreach ($repository->getRepositories() as $repo) { $this->addRepository($repo); } } else { $this->repositories[] = $repository; } } } __halt_compiler();----SIGNATURE:----mxf6iBBlsYp/6TbGS1UcULPiyQjspk4MitOGE9WXjlUmlk4Wi5xhb6XTpoTyj+O9UgCtawDrLmwhsrlOxGp891pqCpyLdJsdUtjPE39zvCThZCo4asC9th8wgKjfwZ858jegMn3CpAMoFVJNF2NqLcBGhFIJl0mmYLnMwB0QlsJPguOzCUZg0zceivUtOSRG9U3waFfLjVrnEFMdh+gGiWdP8W5ReZrXBCPz1x4U7RylVSEfX9v65AgntT7zhEbawVBLg1Q5E4HsZsbie8A2LN/BR4mJa9J6wLNDnjrFogtL8yybmJBXzuGYM4X4hP49pUUPyqvm2FPDYR12ey4uidoEU+SZsxk2KEmAxkk7OcstM5O3rrEqj+b0XhYmvaUXbph7bgID0KNeq3vDOUoretzS8LID56oNy65mrJT0rrH9R1JkbwtrVRHA4IQNp21X1F93kC1CbAwEt+AuJrftKCxXh4j+6ctzgbkZFbVrQgaaMzuwRl/X+xJ8A2QueVUhR0o/k8kpSS+KRMWc/R3ozUCNqADNpq8vR5goSvSxDenMM9RDTa2biko85YOEoV1U/zC14YIq94VFNNEI+fvaDK59FVtZAXJoQ6flwNTj9E7X+orSeKHvGj4CgBjbvf4JARUUcQRVszV7YTM0zPIv8tcaceJXfL/Ud3RZm289g4Q=----ATTACHMENT:----MTkyNzMzMTkyOTM3ODY3IDIxNTQxNDcyMTAxNjAwNTAgNDIzMDgzOTAyMzAxMTk0NA==