HeaderServiceActivator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 3 Features 0
Metric Value
c 4
b 3
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 4
1
<?php
2
3
namespace PEIP\Service;
4
5
/*
6
 * To change this template, choose Tools | Templates
7
 * and open the template in the editor.
8
 */
9
10
/**
11
 * Description of HeaderServiceActivator.
12
 *
13
 * @author timo
14
 */
15
class HeaderServiceActivator extends \PEIP\Service\ServiceActivator
16
{
17
    protected $headerName;
18
19
    /**
20
     * @param $serviceCallable
21
     * @param $inputChannel
22
     * @param $outputChannel
23
     *
24
     * @return
25
     */
26
    public function __construct($serviceCallable, $headerName, \PEIP\INF\Channel\Channel $inputChannel = null, \PEIP\INF\Channel\Channel $outputChannel = null)
27
    {
28
        $this->headerName = $headerName;
29
        parent::__construct($serviceCallable, $inputChannel, $outputChannel);
30
    }
31
32
    /**
33
     * Calls a method on a service (registered as a callable) with
34
     * content/payload of given message as argument.
35
     *
36
     * @param \PEIP\INF\Message\Message $message message to call the service with it�s content/payload
37
     *
38
     * @return mixed result of calling the registered service callable with message content/payload
39
     */
40 View Code Duplication
    protected function callService(\PEIP\INF\Message\Message $message)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42
        $res = null;
43
        if (is_callable($this->serviceCallable)) {
44
            $res = call_user_func($this->serviceCallable, $message->getHeader($this->headerName));
45
        } else {
46
            if (is_object($this->serviceCallable) && method_exists($this->serviceCallable, 'handle')) {
47
                $res = $this->serviceCallable->handle($message->getHeader($this->headerName));
48
            }
49
        }
50
51
        return $res;
52
    }
53
}
54