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...
20
{
21
use ContainerAwareTrait;
22
23
/**
24
* @var string[]
25
*/
26
private $query_handler_ids = [];
27
28
/**
29
* @param Query $query
30
*
31
* @return QueryHandler|null
32
*/
33
public function getQueryHandler(Query $query)
34
{
35
return $this->lazyLoad(get_class($query));
36
}
37
38
/**
39
* @param string $query_name
40
* @param string $service
41
*/
42
public function registerService($query_name, $service)
43
{
44
$this->query_handler_ids[$query_name] = $service;
45
}
46
47
/**
48
* @param $query_name
49
*
50
* @return QueryHandler
51
*/
52
private function lazyLoad($query_name)
53
{
54
if ($this->container instanceof ContainerInterface && 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.