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...
11
{
12
/** @var LoggerInterface */
13
protected $logger;
14
15
/**
16
* CachingCommandBus constructor.
17
*
18
* @param LoggerInterface $logger
19
*/
20
public function __construct(LoggerInterface $logger)
21
{
22
$this->logger = $logger;
23
}
24
25
/**
26
* @param Command $command
27
* @param callable|null $next
28
*/
29
public function __invoke(Command $command, callable $next = null)
30
{
31
try {
32
if ($next) {
33
$this->preCommandLog($command);
34
$next($command);
35
$this->postCommandLog($command);
36
}
37
} catch (Exception $e) {
38
$this->logException($e);
39
}
40
}
41
42
/**
43
* @param Command $command
44
*/
45
protected function preCommandLog(Command $command)
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.