RemittanceInformation::setMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Genkgo\Camt\DTO;
6
7
class RemittanceInformation
8
{
9
    private ?string $message = null;
10
11
    private ?CreditorReferenceInformation $creditorReferenceInformation = null;
12
13
    /**
14
     * @var StructuredRemittanceInformation[]
15
     */
16
    private array $structuredBlocks = [];
17
18
    /**
19
     * @var UnstructuredRemittanceInformation[]
20
     */
21
    private array $unstructuredBlocks = [];
22
23
    public static function fromUnstructured(string $message): self
24
    {
25
        $information = new self();
26
        $information->message = $message;
27
28
        return $information;
29
    }
30
31
    public function getCreditorReferenceInformation(): ?CreditorReferenceInformation
32
    {
33
        return $this->creditorReferenceInformation;
34
    }
35
36
    public function setCreditorReferenceInformation(CreditorReferenceInformation $creditorReferenceInformation): void
37 14
    {
38
        $this->creditorReferenceInformation = $creditorReferenceInformation;
39 14
        $this->message = $creditorReferenceInformation->getRef();
40
    }
41
42 14
    /**
43
     * @deprecated Use getStructuredBlocks method instead
44 14
     */
45 14
    public function getMessage(): ?string
46 14
    {
47
        return $this->message;
48
    }
49
50
    /**
51 11
     * @deprecated Use addStructuredBlock method instead
52
     */
53 11
    public function setMessage(string $message): void
54
    {
55
        $this->message = $message;
56
    }
57
58
    public function addStructuredBlock(StructuredRemittanceInformation $structuredRemittanceInformation): void
59 10
    {
60
        $this->structuredBlocks[] = $structuredRemittanceInformation;
61 10
    }
62 10
63
    /**
64 14
     * @return StructuredRemittanceInformation[]
65
     */
66 14
    public function getStructuredBlocks(): array
67 14
    {
68
        return $this->structuredBlocks;
69
    }
70
71
    public function getStructuredBlock(): ?StructuredRemittanceInformation
72 1
    {
73
        if (isset($this->structuredBlocks[0])) {
74 1
            return $this->structuredBlocks[0];
75
        }
76
77 1
        return null;
78
    }
79 1
80 1
    public function addUnstructuredBlock(UnstructuredRemittanceInformation $unstructuredRemittanceInformation): void
81
    {
82
        $this->unstructuredBlocks[] = $unstructuredRemittanceInformation;
83
    }
84
85
    /**
86 10
     * @return UnstructuredRemittanceInformation[]
87
     */
88 10
    public function getUnstructuredBlocks(): array
89 10
    {
90
        return $this->unstructuredBlocks;
91
    }
92
93
    public function getUnstructuredBlock(): ?UnstructuredRemittanceInformation
94 1
    {
95
        if (isset($this->unstructuredBlocks[0])) {
96 1
            return $this->unstructuredBlocks[0];
97
        }
98
99 1
        return null;
100
    }
101
}
102