|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the Marlon Ogone package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Marlon BVBA <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Ogone\DirectLink; |
|
12
|
|
|
|
|
13
|
|
|
use InvalidArgumentException; |
|
14
|
|
|
|
|
15
|
|
|
class Alias |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
/** @var string */ |
|
19
|
|
|
private $alias; |
|
20
|
|
|
|
|
21
|
|
|
/** @var string */ |
|
22
|
|
|
private $cardName; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string */ |
|
25
|
|
|
private $cardNumber; |
|
26
|
|
|
|
|
27
|
|
|
/** @var string */ |
|
28
|
|
|
private $expiryDate; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param $alias |
|
32
|
|
|
* @param string|null $cardName |
|
33
|
|
|
* @param string|null $cardNumber |
|
34
|
|
|
* @param string|null $expiryDate |
|
35
|
|
|
*/ |
|
36
|
|
|
public function __construct($alias, $cardName = null, $cardNumber = null, $expiryDate = null) |
|
37
|
|
|
{ |
|
38
|
|
|
if (empty($alias)) { |
|
39
|
|
|
throw new InvalidArgumentException("Alias cannot be empty"); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
if (strlen($alias) > 50) { |
|
43
|
|
|
throw new InvalidArgumentException("Alias is too long"); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
if (preg_match('/[^a-zA-Z0-9_-]/', $alias)) { |
|
47
|
|
|
throw new InvalidArgumentException("Alias cannot contain special characters"); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
$this->alias = $alias; |
|
51
|
|
|
$this->cardName = $cardName; |
|
52
|
|
|
$this->cardNumber = $cardNumber; |
|
53
|
|
|
$this->expiryDate = $expiryDate; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function getAlias() |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->alias; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function getCardName() |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->cardName; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function getCardNumber() |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->cardNumber; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function getExpiryDate() |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->expiryDate; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function __toString() |
|
77
|
|
|
{ |
|
78
|
|
|
return (string) $this->alias; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|