-
Notifications
You must be signed in to change notification settings - Fork 164
/
Copy patheppRealName.php
109 lines (107 loc) · 3.63 KB
/
eppRealName.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
// +----------------------------------------------------------------------
// | 在我们年轻的城市里,没有不可能的事!
// +----------------------------------------------------------------------
// | Copyright (c) 2020 http://srs.micang.com All rights reserved.
// +----------------------------------------------------------------------
// | Author : Jansen <[email protected]>
// +----------------------------------------------------------------------
namespace Metaregistrar\EPP;
class eppRealName{
const NAME_ROLE_PERSON = 'person';
const NAME_ROLE_ORG = 'org';
const NAME_PROOF_CITIZEN = 'poc';
const NAME_PROOF_ENTERPRISE = 'poe';
const NAME_PROOF_OTHER_TYPES = 'poot';
/**
* @var string $role
*/
private $role = self::NAME_ROLE_PERSON;
/**
* @var string $name
*/
private $name = '';
/**
* @var string $number
*/
private $number = '';
/**
* @var string $proof
*/
private $proof = self::NAME_PROOF_CITIZEN;
/**
* @var array $documents
*/
private $documents = [];
/**
* @var string $authorisationCode
*/
private $authorisationCode = null;
/**
* eppRealName constructor.
*
* @param string $role
* @param string $name
* @param string $number
* @param string $proof
* @param array $documents
* @param string $authorisationCode
*/
public function __construct(string $role=self::NAME_ROLE_PERSON, string $name='', string $number='', string $proof=self::NAME_PROOF_CITIZEN, array $documents=[], ?string $authorisationCode=null){
!empty($role) && $this->setRole($role);
!empty($name) && $this->setName($name);
!empty($number) && $this->setNumber($number);
!empty($proof) && $this->setProof($proof);
count($documents)>0 && $this->setDocuments($documents);
!empty($authorisationCode) && $this->setAuthorisationCode($authorisationCode);
}
public function setRole(string $role){
if (($role == self::NAME_ROLE_PERSON) || ($role == self::NAME_ROLE_ORG)) {
$this->role = $role;
} else {
throw new eppException("Name role " . $role . " is invalid, only person or org allowed");
}
}
public function getRole(){
return $this->role;
}
public function setName(string $name){
$this->name = $name;
}
public function getName(){
return $this->name;
}
public function setNumber(string $number){
$this->number = $number;
}
public function getNumber(){
return $this->number;
}
public function setProof(string $proof){
if (($proof == self::NAME_PROOF_CITIZEN) || ($proof == self::NAME_PROOF_ENTERPRISE) || ($proof == self::NAME_PROOF_OTHER_TYPES)) {
$this->proof = $proof;
} else {
throw new eppException("Proof Type" . $proof . " is invalid, only poc/poe/poot allowed");
}
}
public function getProof(){
return $this->proof;
}
public function setDocuments(array $documents){
foreach($documents as $doc){
if (!isset($doc['type']) || !isset($doc['content'])){
throw new eppException("Documents must be a two-dimensional array, and must contain type and content elements.");
}
}
$this->documents = $documents;
}
public function getDocuments(){
return $this->documents;
}
public function setAuthorisationCode($authorisationCode) {
$this->authorisationCode = $authorisationCode;
}
public function getAuthorisationCode() {
return $this->authorisationCode;
}
}