Completed
Pull Request — master (#1)
by Adam
06:20 queued 03:33
created

Event::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Equip\Queue;
4
5
use Exception;
6
use League\Event\EmitterInterface;
7
8
class Event
9
{
10
    const QUEUE_ACKNOWLEDGE = 'queue.acknowledge';
11
    const QUEUE_REJECT = 'queue.reject';
12
13
    /**
14
     * @var EmitterInterface
15
     */
16
    private $emitter;
17
18
    /**
19
     * @param EmitterInterface $emitter
20
     */
21
    public function __construct(EmitterInterface $emitter)
22
    {
23
        $this->emitter = $emitter;
24
    }
25
26
    /**
27
     * Emits message acknowledgement events
28
     *
29
     * @param Message $message
30
     */
31 View Code Duplication
    public function acknowledge(Message $message)
0 ignored issues
show
Duplication introduced by
This method 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...
32
    {
33
        array_map(function ($name) use ($message) {
34
            $this->emitter->emit($name, $message);
0 ignored issues
show
Unused Code introduced by
The call to EmitterInterface::emit() has too many arguments starting with $message.

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...
35
        }, [
36
            static::QUEUE_ACKNOWLEDGE,
37
            sprintf('%s.%s', static::QUEUE_ACKNOWLEDGE, $message->handler())
38
        ]);
39
    }
40
41
    /**
42
     * Emits message rejection events
43
     *
44
     * @param Message $message
45
     * @param Exception $exception
46
     */
47 View Code Duplication
    public function reject(Message $message, Exception $exception)
0 ignored issues
show
Duplication introduced by
This method 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...
48
    {
49
        array_map(function ($name) use ($message, $exception) {
50
            $this->emitter->emit($name, $message, $exception);
0 ignored issues
show
Unused Code introduced by
The call to EmitterInterface::emit() has too many arguments starting with $message.

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...
51
        }, [
52
            static::QUEUE_REJECT,
53
            sprintf('%s.%s', static::QUEUE_REJECT, $message->handler())
54
        ]);
55
    }
56
}
57