Passed
Pull Request — master (#417)
by Alejandro
06:44
created

EventListenerTask::toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\EventDispatcher\Listener;
5
6
use Psr\Container\ContainerInterface;
7
use Shlinkio\Shlink\EventDispatcher\Async\TaskInterface;
8
9
use function get_class;
10
use function sprintf;
11
12
class EventListenerTask implements TaskInterface
13
{
14
    /** @var string */
15
    private $listenerName;
16
    /** @var object */
17
    private $event;
18
19 3
    public function __construct(string $listenerName, object $event)
20
    {
21 3
        $this->listenerName = $listenerName;
22 3
        $this->event = $event;
23
    }
24
25 1
    public function run(ContainerInterface $container): void
26
    {
27 1
        ($container->get($this->listenerName))($this->event);
28
    }
29
30 1
    public function toString(): string
31
    {
32 1
        return sprintf('Listener -> "%s", Event -> "%s"', $this->listenerName, get_class($this->event));
33
    }
34
}
35