Passed
Push — feature/post-pay ( 906e88...faf3dd )
by Remco
04:39
created

CustomerInformation::set_email_address()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
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
use DateTimeInterface;
14
15
/**
16
 * Customer information.
17
 *
18
 * @author  Remco Tolsma
19
 * @version 2.0.2
20
 * @since   2.0.2
21
 */
22
class CustomerInformation {
23
	/**
24
	 * The e-mailadress of the consumer.
25
	 *
26
	 * @var string
27
	 */
28
	private $email_address;
29
30
	/**
31
	 * The date of birth of the consumer.
32
	 *
33
	 * @var DateTimeInterface
34
	 */
35
	private $date_of_birth;
36
37
	/**
38
	 * The gender of the consumer.
39
	 *
40
	 * @var string
41
	 */
42
	private $gender;
43
44
	/**
45
	 * The initials of the consumer.
46
	 *
47
	 * @var string
48
	 */
49
	private $initials;
50
51
	/**
52
	 * The consumer's telephone number.
53
	 *
54
	 * @var string
55
	 */
56
	private $telephone_number;
57
58
	/**
59
	 * Set the e-mailadress of the consumer.
60
	 *
61
	 * @param string $email_address E-mailadress of the consumer.
62
	 */
63 1
	public function set_email_address( $email_address ) {
64 1
		$this->email_address = $email_address;
65 1
	}
66
67
	/**
68
	 * Set date of birth.
69
	 *
70
	 * @param DateTimeInterface $date_of_birth Date of birth.
71
	 */
72 1
	public function set_date_of_birth( DateTimeInterface $date_of_birth ) {
73 1
		$this->date_of_birth = $date_of_birth;
74 1
	}
75
76
	/**
77
	 * Set gender.
78
	 *
79
	 * @param string $gender Gender.
80
	 */
81 1
	public function set_gender( $gender ) {
82 1
		$this->gender = $gender;
83 1
	}
84
85
	/**
86
	 * Set initials.
87
	 *
88
	 * @param string $initials Initials.
89
	 */
90 1
	public function set_initials( $initials ) {
91 1
		$this->initials = $initials;
92 1
	}
93
94
	/**
95
	 * Set telephone number.
96
	 *
97
	 * @param string $telephone_number Telephone number.
98
	 */
99 1
	public function set_telephone_number( $telephone_number ) {
100 1
		$this->telephone_number = $telephone_number;
101 1
	}
102
103
	/**
104
	 * Get JSON.
105
	 *
106
	 * @return object|null
107
	 */
108
	public function get_json() {
109
		$object = (object) array();
110
111
		if ( null !== $this->email_address ) {
112
			$object->emailAddress = $this->email_address;
113
		}
114
115
		if ( null !== $this->date_of_birth ) {
116
			$object->dateOfBirth = $this->date_of_birth->format( 'd-m-Y' );
117
		}
118
119
		if ( null !== $this->gender ) {
120
			$object->gender = $this->gender;
121
		}
122
123
		if ( null !== $this->initials ) {
124
			$object->initials = $this->initials;
125
		}
126
127
		if ( null !== $this->telephone_number ) {
128
			$object->telephoneNumber = $this->telephone_number;
129
		}
130
131
		return (object) $data;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $data seems to be never defined.
Loading history...
132
	}
133
134
	/**
135
	 * Get signature fields.
136
	 *
137
	 * @param array $fields Fields.
138
	 * @return array
139
	 */
140 1
	public function get_signature_fields( $fields = array() ) {
141 1
		$fields[] = $this->email_address;
142 1
		$fields[] = ( null === $this->date_of_birth ) ? null : $this->date_of_birth->format( 'd-m-Y' );
143 1
		$fields[] = $this->gender;
144 1
		$fields[] = $this->initials;
145 1
		$fields[] = $this->telephone_number;
146
147 1
		return $fields;
148
	}
149
}
150