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...
9
{
10
/**
11
* Actions registry.
12
*
13
* @var ActionInterface[]
14
*/
15
protected $actions = [];
16
17
/**
18
* Add an Action to the registry.
19
*
20
* @param $id
21
* @param ActionInterface $action
22
*
23
* @throws Exception
24
*/
25
1
public function add($id, ActionInterface $action)
26
{
27
1
if (array_key_exists($id, $this->actions)) {
28
1
throw new Exception('An Action with the name "'.$id.'" has already been registered');
29
}
30
1
$this->actions[$id] = $action;
31
1
}
32
33
/**
34
* Return an Action from the registry.
35
*
36
* @param string $id
37
* @return ActionInterface
38
* @throws Exception
39
*/
40
1
public function get($id)
41
{
42
1
if (!array_key_exists($id, $this->actions)) {
43
1
throw new Exception('No Action with the service id "'.$id.'" has been found');
44
}
45
46
1
return $this->actions[$id];
47
}
48
49
/**
50
* Return true if an Action with the name $id has been registered.
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.