GeneralAccount::format()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Z38\SwissPayment;
4
5
use DOMDocument;
6
use InvalidArgumentException;
7
8
/**
9
 * GeneralAccount holds details about an account which is not covered by any of the other classes
10
 */
11
class GeneralAccount implements AccountInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $id;
17
18
    /**
19
     * Constructor
20
     *
21
     * @param string $id
22
     *
23
     * @throws InvalidArgumentException When the account identification exceeds the maximum length.
24
     */
25 5
    public function __construct($id)
26
    {
27 5
        $this->id = Text::assert($id, 34);
28 4
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 3
    public function format()
34
    {
35 3
        return $this->id;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 2
    public function asDom(DOMDocument $doc)
42
    {
43 2
        $root = $doc->createElement('Id');
44 2
        $other = $doc->createElement('Othr');
45 2
        $other->appendChild(Text::xml($doc, 'Id', $this->format()));
46 2
        $root->appendChild($other);
47
48 2
        return $root;
49
    }
50
}
51