MessageHeaderConfigurator   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 39
ccs 12
cts 13
cp 0.9231
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A configure() 0 20 4
1
<?php
2
3
namespace Happyr\Mq2phpBundle\DependencyInjection\Configurator;
4
5
use Happyr\Mq2phpBundle\Service\HeaderAwareInterface;
6
use Symfony\Component\HttpKernel\KernelInterface;
7
8
/**
9
 * A configurator that will configure the MessageSerialiserDecorator with the mandatory headers.
10
 *
11
 * @author Tobias Nyholm
12
 */
13
class MessageHeaderConfigurator
14
{
15
    /**
16
     * @var \Symfony\Component\HttpKernel\KernelInterface kernel
17
     */
18
    private $kernel;
19
20
    /**
21
     * @param KernelInterface $kernel
22
     */
23 1
    public function __construct(KernelInterface $kernel)
24
    {
25 1
        $this->kernel = $kernel;
26 1
    }
27
28
    /**
29
     * @param HeaderAwareInterface $service
30
     */
31 1
    public function configure(HeaderAwareInterface $service)
32
    {
33
        //try to set default php bin
34 1
        if ($service->getHeader('php_bin') === null) {
35 1
            if (defined(PHP_BINARY)) {
36
                //since php 5.4
37
                $service->setHeader('php_bin', PHP_BINARY);
38
            } else {
39 1
                $service->setHeader('php_bin', PHP_BINDIR.'/php');
40
            }
41
        }
42
43
        //try to set default dispatch_path
44 1
        if ($service->getHeader('dispatch_path') === null) {
45 1
            $service->setHeader(
46 1
                'dispatch_path',
47 1
                $this->kernel->locateResource('@HappyrMq2phpBundle/Resources/bin/dispatch-message.php')
48
            );
49
        }
50 1
    }
51
}
52