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

MessageAdapterFactoryAware   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 24
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setMessageAdapterFactory() 0 6 1
A createMessageAdapter() 0 11 2
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