Completed
Push — master ( 0d5cb2...ca808c )
by Frederik
8s
created

Message   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 2
c 3
b 0
f 2
lcom 0
cbo 2
dl 0
loc 40
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addGroupHeader() 0 10 1
addRecords() 0 1 ?
getRootElement() 0 1 ?
1
<?php
2
3
namespace Genkgo\Camt\Decoder;
4
5
use DateTimeImmutable;
6
use SimpleXMLElement;
7
use Genkgo\Camt\DTO;
8
use Genkgo\Camt\Iban;
9
10
abstract class Message
11
{
12
    /**
13
     * @var Record
14
     */
15
    protected $recordDecoder;
16
17 23
    public function __construct(Record $recordDecoder)
18
    {
19 23
        $this->recordDecoder = $recordDecoder;
20 23
    }
21
22
    /**
23
     * @param DTO\Message      $message
24
     * @param SimpleXMLElement $document
25
     */
26 19
    public function addGroupHeader(DTO\Message $message, SimpleXMLElement $document)
27
    {
28 19
        $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...
29 19
        $groupHeader = new DTO\GroupHeader(
30 19
            (string)$xmlGroupHeader->MsgId,
31 19
            new DateTimeImmutable((string)$xmlGroupHeader->CreDtTm)
32 19
        );
33
34 19
        $message->setGroupHeader($groupHeader);
35 19
    }
36
37
    /**
38
     * @param DTO\Message      $message
39
     * @param SimpleXMLElement $document
40
     */
41
    abstract public function addRecords(DTO\Message $message, SimpleXMLElement $document);
42
43
    /**
44
     * @param SimpleXMLElement $document
45
     *
46
     * @return SimpleXMLElement
47
     */
48
    abstract public function getRootElement(SimpleXMLElement $document);
49
}
50