Failed Conditions
Push — master ( b549f2...090668 )
by Remco
10:21 queued 03:46
created

Profile::get_id()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * Mollie profile.
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2020 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Mollie;
12
13
/**
14
 * Mollie profile.
15
 *
16
 * @link    https://docs.mollie.com/reference/v2/profiles-api/create-profile
17
 * @author  Remco Tolsma
18
 * @version 2.1.0
19
 * @since   2.1.0
20
 */
21
class Profile {
22
	/**
23
	 * ID.
24
	 *
25
	 * @var string|null
26
	 */
27
	private $id;
28
29
	/**
30
	 * Mode.
31
	 *
32
	 * @var string|null
33
	 */
34
	private $mode;
35
36
	/**
37
	 * Name.
38
	 *
39
	 * @var string|null
40
	 */
41
	private $name;
42
43
	/**
44
	 * Email.
45
	 *
46
	 * @var string|null
47
	 */
48
	private $email;
49
50
	/**
51
	 * Get ID.
52
	 *
53
	 * @return string|null
54
	 */
55 1
	public function get_id() {
56 1
		return $this->id;
57
	}
58
59
	/**
60
	 * Set ID.
61
	 *
62
	 * @param string|null $id ID.
63
	 * @return void
64
	 */
65 1
	public function set_id( $id ) {
66 1
		$this->id = $id;
67 1
	}
68
69
	/**
70
	 * Get mode.
71
	 *
72
	 * @return string|null
73
	 */
74 1
	public function get_mode() {
75 1
		return $this->mode;
76
	}
77
78
	/**
79
	 * Set mode.
80
	 *
81
	 * @param string|null $mode Mode.
82
	 * @return void
83
	 */
84 1
	public function set_mode( $mode ) {
85 1
		$this->mode = $mode;
86 1
	}
87
88
	/**
89
	 * Get name.
90
	 *
91
	 * @return string|null
92
	 */
93 1
	public function get_name() {
94 1
		return $this->name;
95
	}
96
97
	/**
98
	 * Set name.
99
	 *
100
	 * @param string|null $name Name.
101
	 * @return void
102
	 */
103 1
	public function set_name( $name ) {
104 1
		$this->name = $name;
105 1
	}
106
107
	/**
108
	 * Get email.
109
	 *
110
	 * @return string|null
111
	 */
112 1
	public function get_email() {
113 1
		return $this->email;
114
	}
115
116
	/**
117
	 * Set email.
118
	 *
119
	 * @param string|null $email Email.
120
	 * @return void
121
	 */
122 1
	public function set_email( $email ) {
123 1
		$this->email = $email;
124 1
	}
125
126
	/**
127
	 * Create profile from object.
128
	 *
129
	 * @param object $object Object.
130
	 * @return Profile
131
	 */
132
	public static function from_object( $object ) {
133
		$profile = new self();
134
135
		if ( property_exists( $object, 'id' ) ) {
136
			$profile->set_id( $object->id );
137
		}
138
139
		if ( property_exists( $object, 'mode' ) ) {
140
			$profile->set_mode( $object->mode );
141
		}
142
143
		if ( property_exists( $object, 'name' ) ) {
144
			$profile->set_name( $object->name );
145
		}
146
147
		if ( property_exists( $object, 'email' ) ) {
148
			$profile->set_email( $object->email );
149
		}
150
151
		return $profile;
152
	}
153
}
154