Failed Conditions
Push — develop ( 254456...8742c8 )
by Remco
05:38
created

Currency::set_name()   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
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
/**
3
 * Currency
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2019 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Money
9
 */
10
11
namespace Pronamic\WordPress\Money;
12
13
/**
14
 * Currency
15
 *
16
 * @author  Remco Tolsma
17
 * @version 1.2.1
18
 * @since   1.0.0
19
 */
20
class Currency {
21
	/**
22
	 * Alphabetic code.
23
	 *
24
	 * @var string|null
25
	 */
26
	private $alphabetic_code;
27
28
	/**
29
	 * Numeric code.
30
	 *
31
	 * @var string|null
32
	 */
33
	private $numeric_code;
34
35
	/**
36
	 * Symbol.
37
	 *
38
	 * @var string|null
39
	 */
40
	private $symbol;
41
42
	/**
43
	 * Name.
44
	 *
45
	 * @var string|null
46
	 */
47
	private $name;
48
49
	/**
50
	 * Number decimals.
51
	 *
52
	 * @var int
53
	 */
54
	private $number_decimals;
55
56
	/**
57
	 * Construct and initialize currency object.
58
	 */
59 74
	public function __construct() {
60 74
		$this->set_number_decimals( 2 );
61 74
	}
62
63
	/**
64
	 * Get alphabetic code.
65
	 *
66
	 * @return string|null
67
	 */
68 14
	public function get_alphabetic_code() {
69 14
		return $this->alphabetic_code;
70
	}
71
72
	/**
73
	 * Set alphabetic code.
74
	 *
75
	 * @param string|null $alphabetic_code Alphabetic code.
76
	 * @return void
77
	 */
78 1
	public function set_alphabetic_code( $alphabetic_code ) {
79 1
		$this->alphabetic_code = $alphabetic_code;
80 1
	}
81
82
	/**
83
	 * Get numeric code.
84
	 *
85
	 * @return string|null
86
	 */
87
	public function get_numeric_code() {
88
		return $this->numeric_code;
89
	}
90
91
	/**
92
	 * Set numeric code.
93
	 *
94
	 * @param string|null $numeric_code Numeric code.
95
	 * @return void
96
	 */
97 1
	public function set_numeric_code( $numeric_code ) {
98 1
		$this->numeric_code = $numeric_code;
99 1
	}
100
101
	/**
102
	 * Get symbol.
103
	 *
104
	 * @return string|null
105
	 */
106 14
	public function get_symbol() {
107 14
		return $this->symbol;
108
	}
109
110
	/**
111
	 * Set symbol.
112
	 *
113
	 * @param string|null $symbol Symbol.
114
	 * @return void
115
	 */
116 1
	public function set_symbol( $symbol ) {
117 1
		$this->symbol = $symbol;
118 1
	}
119
120
	/**
121
	 * Get number decimals.
122
	 *
123
	 * @return int
124
	 */
125 35
	public function get_number_decimals() {
126 35
		return $this->number_decimals;
127
	}
128
129
	/**
130
	 * Set number decimals.
131
	 *
132
	 * @param int $number_decimals Number of decimals.
133
	 * @return void
134
	 */
135 74
	public function set_number_decimals( $number_decimals ) {
136 74
		$this->number_decimals = intval( $number_decimals );
137 74
	}
138
139
	/**
140
	 * Get instance.
141
	 *
142
	 * @param string $alphabetic_code Alphabetic code.
143
	 *
144
	 * @return Currency
145
	 */
146 74
	public static function get_instance( $alphabetic_code ) {
147 74
		return Currencies::get_currency( $alphabetic_code );
148
	}
149
150
	/**
151
	 * Get name.
152
	 *
153
	 * @return string|null
154
	 */
155
	public function get_name() {
156
		return $this->name;
157
	}
158
159
	/**
160
	 * Set name.
161
	 *
162
	 * @param string|null $name Currency name.
163
	 * @return void
164
	 */
165 1
	public function set_name( $name ) {
166 1
		$this->name = $name;
167 1
	}
168
}
169