Skip to content

Commit b23fa20

Browse files
committed
Add type-hints on signatures of repository-manager methods
1 parent ec65289 commit b23fa20

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

src/Manager/RepositoryManager.php

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use FOS\ElasticaBundle\Finder\FinderInterface;
1515
use FOS\ElasticaBundle\Repository;
16-
use RuntimeException;
1716

1817
/**
1918
* @author Richard Miller <[email protected]>
@@ -26,20 +25,14 @@ class RepositoryManager implements RepositoryManagerInterface
2625
/**
2726
* @var array
2827
*/
29-
private $indexes;
28+
private $indexes = [];
3029

3130
/**
3231
* @var array
3332
*/
34-
private $repositories;
33+
private $repositories = [];
3534

36-
public function __construct()
37-
{
38-
$this->indexes = [];
39-
$this->repositories = [];
40-
}
41-
42-
public function addIndex(string $indexName, FinderInterface $finder, string $repositoryName = null): void
35+
public function addIndex(string $indexName, FinderInterface $finder, ?string $repositoryName = null): void
4336
{
4437
$this->indexes[$indexName] = [
4538
'finder' => $finder,
@@ -60,7 +53,7 @@ public function getRepository(string $indexName): Repository
6053
}
6154

6255
if (!$this->hasRepository($indexName)) {
63-
throw new RuntimeException(sprintf('No search finder configured for %s', $indexName));
56+
throw new \RuntimeException(sprintf('No repository configured for %s', $indexName));
6457
}
6558

6659
$repository = $this->createRepository($indexName);
@@ -74,12 +67,7 @@ public function hasRepository(string $indexName): bool
7467
return isset($this->indexes[$indexName]);
7568
}
7669

77-
/**
78-
* @param $indexName
79-
*
80-
* @return string
81-
*/
82-
protected function getRepositoryName($indexName)
70+
protected function getRepositoryName(string $indexName): string
8371
{
8472
if (isset($this->indexes[$indexName]['repositoryName'])) {
8573
return $this->indexes[$indexName]['repositoryName'];
@@ -89,14 +77,12 @@ protected function getRepositoryName($indexName)
8977
}
9078

9179
/**
92-
* @param $indexName
93-
*
9480
* @return mixed
9581
*/
96-
private function createRepository($indexName)
82+
private function createRepository(string $indexName)
9783
{
9884
if (!class_exists($repositoryName = $this->getRepositoryName($indexName))) {
99-
throw new RuntimeException(sprintf('%s repository for %s does not exist', $repositoryName, $indexName));
85+
throw new \RuntimeException(sprintf('%s repository for %s does not exist', $repositoryName, $indexName));
10086
}
10187

10288
return new $repositoryName($this->indexes[$indexName]['finder']);

0 commit comments

Comments
 (0)