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
|
11 |
|
public function __construct($alias, $cardName = null, $cardNumber = null, $expiryDate = null) |
37
|
|
|
{ |
38
|
11 |
|
if (empty($alias)) { |
39
|
2 |
|
throw new InvalidArgumentException("Alias cannot be empty"); |
40
|
|
|
} |
41
|
|
|
|
42
|
9 |
|
if (strlen($alias) > 50) { |
43
|
3 |
|
throw new InvalidArgumentException("Alias is too long"); |
44
|
|
|
} |
45
|
|
|
|
46
|
6 |
|
if (preg_match('/[^a-zA-Z0-9_-]/', $alias)) { |
47
|
2 |
|
throw new InvalidArgumentException("Alias cannot contain special characters"); |
48
|
|
|
} |
49
|
|
|
|
50
|
4 |
|
$this->alias = $alias; |
51
|
4 |
|
$this->cardName = $cardName; |
52
|
4 |
|
$this->cardNumber = $cardNumber; |
53
|
4 |
|
$this->expiryDate = $expiryDate; |
54
|
4 |
|
} |
55
|
|
|
|
56
|
1 |
|
public function getAlias() |
57
|
|
|
{ |
58
|
1 |
|
return $this->alias; |
59
|
|
|
} |
60
|
|
|
|
61
|
1 |
|
public function getCardName() |
62
|
|
|
{ |
63
|
1 |
|
return $this->cardName; |
64
|
|
|
} |
65
|
|
|
|
66
|
1 |
|
public function getCardNumber() |
67
|
|
|
{ |
68
|
1 |
|
return $this->cardNumber; |
69
|
|
|
} |
70
|
|
|
|
71
|
1 |
|
public function getExpiryDate() |
72
|
|
|
{ |
73
|
1 |
|
return $this->expiryDate; |
74
|
|
|
} |
75
|
|
|
|
76
|
4 |
|
public function __toString() |
77
|
|
|
{ |
78
|
4 |
|
return (string) $this->alias; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|