Test Failed
Push — feature/post-pay ( e3663d...906e88 )
by Remco
04:22
created

CustomerInformation::get_signature_fields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 8
ccs 0
cts 7
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Customer information.
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2018 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\OmniKassa2
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\OmniKassa2;
12
13
/**
14
 * Customer information.
15
 *
16
 * @author  Remco Tolsma
17
 * @version 2.0.2
18
 * @since   2.0.2
19
 */
20
class CustomerInformation {
21
	/**
22
	 * The e-mailadress of the consumer.
23
	 *
24
	 * @var string
25
	 */
26
	private $email_address;
27
28
	/**
29
	 * The date of birth of the consumer.
30
	 *
31
	 * @var string
32
	 */
33
	private $date_of_birth;
34
35
	/**
36
	 * The gender of the consumer.
37
	 *
38
	 * @var string
39
	 */
40
	private $gender;
41
42
	/**
43
	 * The initials of the consumer.
44
	 *
45
	 * @var string
46
	 */
47
	private $initials;
48
49
	/**
50
	 * The consumer's telephone number.
51
	 *
52
	 * @var string
53
	 */
54
	private $telephone_number;
55
56
	/**
57
	 * Set the e-mailadress of the consumer.
58
	 *
59
	 * @param string $email_address E-mailadress of the consumer.
60
	 */
61
	public function set_email_address( $email_address ) {
62
		$this->email_address = $email_address;
63
	}
64
65
	/**
66
	 * Set date of birth.
67
	 *
68
	 * @param string $date_of_birth Date of birth.
69
	 */
70
	public function set_date_of_birth( $date_of_birth ) {
71
		$this->date_of_birth = $date_of_birth;
72
	}
73
74
	/**
75
	 * Set gender.
76
	 *
77
	 * @param string $gender Gender.
78
	 */
79
	public function set_gender( $gender ) {
80
		$this->gender = $gender;
81
	}
82
83
	/**
84
	 * Set initials.
85
	 *
86
	 * @param string $initials Initials.
87
	 */
88
	public function set_initials( $initials ) {
89
		$this->initials = $initials;
90
	}
91
92
	/**
93
	 * Set telephone number.
94
	 *
95
	 * @param string $telephone_number Telephone number.
96
	 */
97
	public function set_telephone_number( $telephone_number ) {
98
		$this->telephone_number = $telephone_number;
99
	}
100
101
	/**
102
	 * Get JSON.
103
	 *
104
	 * @return object|null
105
	 */
106
	public function get_json() {
107
		$data = array(
108
			'emailAddress'    => $this->email_address,
109
			'dateOfBirth'     => $this->date_of_birth,
110
			'gender'          => $this->gender,
111
			'initials'        => $this->initials,
112
			'telephoneNumber' => $this->telephone_number,
113
		);
114
115
		$data = array_filter( $data );
116
117
		if ( empty( $data ) ) {
118
			return null;
119
		}
120
121
		return (object) $data;
122
	}
123
124
	/**
125
	 * Get signature fields.
126
	 *
127
	 * @param array $fields Fields.
128
	 * @return array
129
	 */
130
	public function get_signature_fields( $fields = array() ) {
131
		$fields[] = $this->email_address;
132
		$fields[] = $this->date_of_birth;
133
		$fields[] = $this->gender;
134
		$fields[] = $this->initials;
135
		$fields[] = $this->telephone_number;
136
137
		return $fields;
138
	}
139
}
140