Completed
Pull Request — master (#9)
by Nicolas
03:08
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 4
    public function __construct(\Closure $worker, Consumer $consumer, $queue)
23
    {
24 4
        $this->worker = $worker;
25 4
        $this->consumer = $consumer;
26 4
        $this->queue = $queue;
27 4
        $this->logger = new NullLogger();
28 4
    }
29
30 1
    public function getWorker()
31
    {
32 1
        if($this->worker instanceof \Closure)
33 1
        {
34 1
            $closure = $this->worker;
35 1
            $this->worker = $closure();
36 1
            $this->worker->setLogger($this->logger);
37 1
        }
38
39 1
        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 1
    public function getLogger()
51
    {
52 1
        return $this->logger;
53
    }
54
55
    public function getConsumer()
56
    {
57
        return $this->consumer;
58
    }
59
60 1
    public function setDescription($description)
61
    {
62 1
        $this->description = $description;
63
64 1
        return $this;
65
    }
66
67 2
    public function getDescription()
68
    {
69 2
        return $this->description;
70
    }
71
72 3
    public function getQueue()
73
    {
74 3
        return $this->queue;
75
    }
76
}
77