Passed
Push — master ( d1ccc3...a5920b )
by Nicolas
04:01
created

setMessageAdapterFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Puzzle\AMQP\Workers;
4
5
trait MessageAdapterFactoryAware
6
{
7
    private
8
        $messageAdapterFactory;
9
    
10 2
    public function setMessageAdapterFactory(MessageAdapterFactory $factory = null)
11
    {
12 2
        $this->messageAdapterFactory = $factory;
13
        
14 2
        return $this;
15
    }
16
    
17 4
    public function createMessageAdapter(\Swarrot\Broker\Message $message)
18
    {
19 4
        $factory = $this->messageAdapterFactory;
20
        
21 4
        if(! $factory instanceof MessageAdapterFactory)
22 4
        {
23 3
            $factory = new MessageAdapterFactory();
24 3
        }
25
        
26 4
        return $factory->build($message);
27
    }
28
}
29