1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Passbook package. |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Passbook\Pass; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* NFC |
14
|
|
|
*/ |
15
|
|
|
class Nfc implements NfcInterface |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* NFC message |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
protected $message = ''; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Encryption Public Key |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $encryptionPublicKey = ''; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var boolean |
31
|
|
|
*/ |
32
|
|
|
protected $requiresAuthentication = false; |
33
|
|
|
|
34
|
2 |
|
public function __construct($message, $encryptionPublicKey, $requiresAuthentication = false) |
35
|
|
|
{ |
36
|
2 |
|
$this->setMessage($message); |
37
|
2 |
|
$this->setEncryptionPublicKey($encryptionPublicKey); |
38
|
2 |
|
$this->setRequiresAuthentication($requiresAuthentication); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
2 |
|
public function setMessage($message) |
45
|
|
|
{ |
46
|
2 |
|
$this->message = $message; |
47
|
2 |
|
return $this; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
*/ |
53
|
2 |
|
public function setEncryptionPublicKey($encryptionPublicKey) |
54
|
|
|
{ |
55
|
2 |
|
$this->encryptionPublicKey = $encryptionPublicKey; |
56
|
2 |
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritdoc} |
61
|
|
|
*/ |
62
|
2 |
|
public function setRequiresAuthentication(bool $requiresAuthentication) |
63
|
|
|
{ |
64
|
2 |
|
$this->requiresAuthentication = $requiresAuthentication; |
65
|
2 |
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
2 |
|
public function toArray() |
69
|
|
|
{ |
70
|
2 |
|
$array = [ |
71
|
2 |
|
'message' => $this->getMessage(), |
72
|
2 |
|
'encryptionPublicKey' => $this->getEncryptionPublicKey(), |
73
|
2 |
|
'requiresAuthentication' => $this->getRequiresAuthentication() |
74
|
2 |
|
]; |
75
|
2 |
|
return $array; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritdoc} |
80
|
|
|
*/ |
81
|
2 |
|
public function getMessage() |
82
|
|
|
{ |
83
|
2 |
|
return $this->message; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* {@inheritdoc} |
88
|
|
|
*/ |
89
|
2 |
|
public function getEncryptionPublicKey() |
90
|
|
|
{ |
91
|
2 |
|
return $this->encryptionPublicKey; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* {@inheritdoc} |
96
|
|
|
*/ |
97
|
2 |
|
public function getRequiresAuthentication() |
98
|
|
|
{ |
99
|
2 |
|
return $this->requiresAuthentication; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|