Completed
Push — master ( ca808c...de2f5d )
by Frederik
02:56
created

Message::addGroupHeader()   B

Complexity

Conditions 4
Paths 5

Size

Total Lines 28
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 22
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 28
ccs 22
cts 22
cp 1
rs 8.5806
cc 4
eloc 15
nc 5
nop 2
crap 4
1
<?php
2
3
namespace Genkgo\Camt\Camt054\Decoder\V04;
4
5
use Genkgo\Camt\Camt054\Decoder\Message as BaseMessage;
6
use Genkgo\Camt\Camt054\DTO\V04 as Camt054V04DTO;
7
use Genkgo\Camt\DTO;
8
use SimpleXMLElement;
9
use DateTimeImmutable;
10
11
class Message extends BaseMessage
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 3
    public function addGroupHeader(DTO\Message $message, SimpleXMLElement $document)
17
    {
18 3
        $xmlGroupHeader = $this->getRootElement($document)->GrpHdr;
0 ignored issues
show
Bug introduced by
The property GrpHdr does not seem to exist in SimpleXMLElement.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
19 3
        $groupHeader = new Camt054V04DTO\GroupHeader(
20 3
            (string)$xmlGroupHeader->MsgId,
21 3
            new DateTimeImmutable((string)$xmlGroupHeader->CreDtTm)
22 3
        );
23
24 3
        if (isset($xmlGroupHeader->OrgnlBizQry)) {
25 3
            $originalBusinessQuery = new Camt054V04DTO\OriginalBusinessQuery(
26 3
                (string) $xmlGroupHeader->OrgnlBizQry->MsgId
27 3
            );
28
29 3
            if (isset($xmlGroupHeader->OrgnlBizQry->CreDtTm)) {
30 3
                $originalBusinessQuery->setCreatedOn(
31 3
                    new DateTimeImmutable((string) $xmlGroupHeader->OrgnlBizQry->CreDtTm)
32 3
                );
33 3
            }
34
35 3
            if (isset($xmlGroupHeader->OrgnlBizQry->MsgNmId)) {
36 3
                $originalBusinessQuery->setMessageNameId((string) $xmlGroupHeader->OrgnlBizQry->MsgNmId);
37 3
            }
38
39 3
            $groupHeader->setOriginalBusinessQuery($originalBusinessQuery);
40 3
        }
41
42 3
        $message->setGroupHeader($groupHeader);
43 3
    }
44
}
45