Failed Conditions
Push — develop ( ceb48c...a5351c )
by Remco
12:56
created

Name::set_first_name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Name
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2019 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\OmniKassa2
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Adyen;
12
13
/**
14
 * Name
15
 *
16
 * @link https://docs.adyen.com/developers/api-reference/common-api/name
17
 *
18
 * @author  Remco Tolsma
19
 * @version 2.1.0
20
 * @since   2.0.2
21
 */
22
class Name {
23
	/**
24
	 * First name.
25
	 *
26
	 * @var string
27
	 */
28
	private $first_name;
29
30
	/**
31
	 * Gender.
32
	 *
33
	 * @var string
34
	 */
35
	private $gender;
36
37
	/**
38
	 * The name's infix, if applicable.
39
	 *
40
	 * @var string|null
41
	 */
42
	private $infix;
43
44
	/**
45
	 * Last name.
46
	 *
47
	 * @var string
48
	 */
49
	private $last_name;
50
51
	/**
52
	 * Construct shopper name.
53
	 *
54
	 * @param string $first_name First name.
55
	 * @param string $last_name  Last name.
56
	 * @param string $gender     Gender.
57
	 */
58
	public function __construct( $first_name, $last_name, $gender ) {
59
		$this->set_first_name( $first_name );
60
		$this->set_last_name( $last_name );
61
		$this->set_gender( $gender );
62
	}
63
64
	/**
65
	 * Get first name.
66
	 *
67
	 * @return string
68
	 */
69
	public function get_first_name() {
70
		return $this->first_name;
71
	}
72
73
	/**
74
	 * Set first name.
75
	 *
76
	 * @param string $first_name First name.
77
	 */
78
	public function set_first_name( $first_name ) {
79
		$this->first_name = $first_name;
80
	}
81
82
	/**
83
	 * Get gender.
84
	 *
85
	 * @return string
86
	 */
87
	public function get_gender() {
88
		return $this->gender;
89
	}
90
91
	/**
92
	 * Set gender.
93
	 *
94
	 * @param string $gender Gender.
95
	 */
96
	public function set_gender( $gender ) {
97
		$this->gender = $gender;
98
	}
99
100
	/**
101
	 * Get infix.
102
	 *
103
	 * @return string|null
104
	 */
105
	public function get_infix() {
106
		return $this->infix;
107
	}
108
109
	/**
110
	 * Set infix.
111
	 *
112
	 * @param string|null $infix Infix.
113
	 */
114
	public function set_infix( $infix ) {
115
		$this->infix = $infix;
116
	}
117
118
	/**
119
	 * Get last name.
120
	 *
121
	 * @return string
122
	 */
123
	public function get_last_name() {
124
		return $this->last_name;
125
	}
126
127
	/**
128
	 * Set last name.
129
	 *
130
	 * @param string $last_name Last name.
131
	 */
132
	public function set_last_name( $last_name ) {
133
		$this->last_name = $last_name;
134
	}
135
136
	/**
137
	 * Get JSON.
138
	 *
139
	 * @return object
140
	 */
141
	public function get_json() {
142
		$object = (object) array();
143
144
		// First name.
145
		$object->firstName = $this->get_first_name();
146
147
		// Gender.
148
		$object->gender = $this->get_gender();
149
150
		// Infix.
151
		$infix = $this->get_infix();
152
153
		if ( null !== $infix ) {
154
			$object->infix = $infix;
155
		}
156
157
		// Last name.
158
		$object->lastName = $this->get_last_name();
159
160
		// Return object.
161
		return $object;
162
	}
163
}
164