Completed
Push — master ( 613d98...fa04c9 )
by Rémi
20:40
created

AsyncPublisher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A publish() 0 6 1
1
<?php
2
3
namespace Burrow\Publisher;
4
5
use Burrow\Driver;
6
use Burrow\Message;
7
use Burrow\QueuePublisher;
8
9
class AsyncPublisher implements QueuePublisher
10
{
11
    /** @var Driver */
12
    private $driver;
13
14
    /** @var string */
15
    private $exchangeName;
16
17
    /**
18
     * Constructor
19
     *
20
     * @param Driver $driver
21
     * @param string $exchangeName
22
     */
23
    public function __construct(Driver $driver, $exchangeName)
24
    {
25
        $this->driver = $driver;
26
        $this->exchangeName = $exchangeName;
27
    }
28
29
    /**
30
     * Publish a message on the queue
31
     *
32
     * @param mixed   $data
33
     * @param string   $routingKey
34
     * @param string[] $headers
35
     *
36
     * @return mixed
37
     */
38
    public function publish($data, $routingKey = '', array $headers = [])
39
    {
40
        $this->driver->publish($this->exchangeName, new Message($data, $routingKey, $headers));
0 ignored issues
show
Documentation introduced by
$headers is of type array<integer,string>, but the function expects a array<integer,object<string>>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
41
42
        return null;
43
    }
44
}
45