Completed
Push — ws-security ( 6a0e45...74bdbb )
by Asmir
56:13 queued 26:15
created

WssSecurityHeaderHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 32
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribingMethods() 0 11 1
A __construct() 0 4 1
A serializeHeader() 0 7 1
1
<?php
2
namespace GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\Serializer;
3
4
5
use GoetasWebservices\SoapServices\SoapClient\WssWsSecurity\Security;
6
use JMS\Serializer\GraphNavigator;
7
use JMS\Serializer\Handler\SubscribingHandlerInterface;
8
use JMS\Serializer\SerializationContext;
9
use JMS\Serializer\XmlSerializationVisitor;
10
11
class WssSecurityHeaderHandler implements SubscribingHandlerInterface
12
{
13
    /**
14
     * @var WsSecurityFilterRequest
15
     */
16
    protected $filter;
17
18
    public static function getSubscribingMethods()
19
    {
20
        return array(
21
            array(
22
                'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
23
                'format' => 'xml',
24
                'type' => Security::class,
25
                'method' => 'serializeHeader'
26
            ),
27
        );
28
    }
29
30
    public function __construct(WsSecurityFilterRequest $filter)
31
    {
32
        $this->filter = $filter;
33
    }
34
35
    public function serializeHeader(XmlSerializationVisitor $visitor, Security $data, array $type, SerializationContext $context)
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
        $currentNode = $visitor->getCurrentNode();
38
        $securityHeader = $this->filter->filterDom($currentNode, $data);
39
        $visitor->revertCurrentNode();
40
        $visitor->setCurrentNode($securityHeader);
41
    }
42
}
43