forked from z38/swiss-payment
-
Notifications
You must be signed in to change notification settings - Fork 6
/
GeneralAccount.php
50 lines (43 loc) · 980 Bytes
/
GeneralAccount.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Z38\SwissPayment;
use DOMDocument;
use InvalidArgumentException;
/**
* GeneralAccount holds details about an account which is not covered by any of the other classes
*/
class GeneralAccount implements AccountInterface
{
/**
* @var string
*/
protected $id;
/**
* Constructor
*
* @param string $id
*
* @throws InvalidArgumentException When the account identification exceeds the maximum length.
*/
public function __construct($id)
{
$this->id = Text::assert($id, 34);
}
/**
* {@inheritdoc}
*/
public function format()
{
return $this->id;
}
/**
* {@inheritdoc}
*/
public function asDom(DOMDocument $doc)
{
$root = $doc->createElement('Id');
$other = $doc->createElement('Othr');
$other->appendChild(Text::xml($doc, 'Id', $this->format()));
$root->appendChild($other);
return $root;
}
}