This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
18
{
19
/**
20
* @var ContainerInterface
21
*/
22
private $container;
23
24
/**
25
* @var string[]
26
*/
27
private $query_handler_ids = [];
28
29
/**
30
* @param ContainerInterface $container
31
*/
32
public function __construct(ContainerInterface $container)
33
{
34
$this->container = $container;
35
}
36
37
/**
38
* @param Query $query
39
*
40
* @return QueryHandler|null
41
*/
42
public function getQueryHandler(Query $query)
43
{
44
return $this->lazyLoad(get_class($query));
45
}
46
47
/**
48
* @param string $query_name
49
* @param string $service
50
*/
51
public function registerService($query_name, $service)
52
{
53
$this->query_handler_ids[$query_name] = $service;
54
}
55
56
/**
57
* @param $query_name
58
*
59
* @return QueryHandler
60
*/
61
private function lazyLoad($query_name)
62
{
63
if (isset($this->query_handler_ids[$query_name])) {
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.