Test Failed
Pull Request — master (#9)
by Nicolas
03:28
created

WorkerContext::deployOn()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
ccs 0
cts 12
cp 0
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
crap 12
1
<?php
2
3
namespace Puzzle\AMQP\Workers;
4
5
use Psr\Log\LoggerAwareTrait;
6
use Puzzle\AMQP\Consumer;
7
use Psr\Log\LoggerInterface;
8
use Psr\Log\NullLogger;
9
10
class WorkerContext
11
{
12
    use LoggerAwareTrait;
13
14
    public
15
        $queue,
1 ignored issue
show
Coding Style introduced by
The visibility should be declared for property $queue.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
16
        $description;
17
18
    private
19
        $consumer,
1 ignored issue
show
Coding Style introduced by
The visibility should be declared for property $consumer.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
20
        $worker;
21
22
    public function __construct(\Closure $worker, Consumer $consumer, $queue)
23
    {
24
        $this->worker = $worker;
25
        $this->consumer = $consumer;
26
        $this->queue = $queue;
27
        $this->logger = new NullLogger();
28
    }
29
30
    public function getWorker()
31
    {
32
        if($this->worker instanceof \Closure)
33
        {
34
            $closure = $this->worker;
35
            $this->worker = $closure();
36
            $this->worker->setLogger($this->logger);
37
        }
38
39
        return $this->worker;
40
    }
41
42
    public function setLogger(LoggerInterface $logger)
43
    {
44
        $this->logger = $logger;
45
        $this->consumer->setLogger($logger);
46
47
        return $this;
48
    }
49
50
    public function getLogger()
51
    {
52
        return $this->logger;
53
    }
54
55
    public function getConsumer()
56
    {
57
        return $this->consumer;
58
    }
59
60
    public function setDescription($description)
61
    {
62
        $this->description = $description;
63
64
        return $this;
65
    }
66
67
    public function getDescription()
68
    {
69
        return $this->description;
70
    }
71
72
    public function getQueue()
73
    {
74
        return $this->queue;
75
    }
76
}
77