Completed
Push — master ( 0b4c0a...f06a3d )
by Adam
14:19
created

Event::shutdown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 11
loc 11
ccs 8
cts 8
cp 1
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Equip\Queue;
4
5
use Equip\Command\OptionsInterface;
6
use Exception;
7
use League\Event\EmitterInterface;
8
use Psr\Log\LoggerInterface;
9
10
class Event
11
{
12
    const MESSAGE_ACKNOWLEDGE = 'message.acknowledge';
13
    const MESSAGE_FINISH = 'message.finish';
14
    const MESSAGE_REJECT = 'message.reject';
15
    const QUEUE_SHUTDOWN = 'queue.shutdown';
16
17
    /**
18
     * @var EmitterInterface
19
     */
20
    private $emitter;
21
22
    /**
23
     * @var LoggerInterface
24
     */
25
    protected $logger;
26
27
    /**
28
     * @param EmitterInterface $emitter
29
     * @param LoggerInterface $logger
30
     */
31 3
    public function __construct(EmitterInterface $emitter, LoggerInterface $logger)
32
    {
33 3
        $this->emitter = $emitter;
34 3
        $this->logger = $logger;
35 3
    }
36
37
    /**
38
     * Emits message acknowledgement events
39
     *
40
     * @param object $command
41
     */
42 1
    public function acknowledge($command)
43
    {
44 1
        $this->emitter->emit(static::MESSAGE_ACKNOWLEDGE, $command);
0 ignored issues
show
Unused Code introduced by
The call to EmitterInterface::emit() has too many arguments starting with $command.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
45 1
        $this->logger->info(sprintf('`%s` job started', get_class($command)));
46 1
    }
47
48
    /**
49
     * Emits message finished events
50
     *
51
     * @param object $command
52
     */
53 1
    public function finish($command)
54
    {
55 1
        $this->emitter->emit(static::MESSAGE_FINISH, $command);
0 ignored issues
show
Unused Code introduced by
The call to EmitterInterface::emit() has too many arguments starting with $command.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
56 1
        $this->logger->info(sprintf('`%s` job finished', get_class($command)));
57 1
    }
58
59
    /**
60
     * Emits message rejection events
61
     *
62
     * @param object $command
63
     * @param Exception $exception
64
     */
65 1
    public function reject($command, Exception $exception)
66
    {
67 1
        $this->emitter->emit(static::MESSAGE_REJECT, $command, $exception);
0 ignored issues
show
Unused Code introduced by
The call to EmitterInterface::emit() has too many arguments starting with $command.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
68 1
        $this->logger->error($exception->getMessage());
69 1
    }
70
}
71