Failed Conditions
Push — develop ( 612159...14294b )
by Reüel
03:14
created

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