Failed Conditions
Push — develop ( e4f983...8cba91 )
by Remco
04:22
created

Error::get_code()   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 0
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\TargetPay;
4
5
/**
6
 * Title: TargetPay error
7
 * Description:
8
 * Copyright: 2005-2021 Pronamic
9
 * Company: Pronamic
10
 *
11
 * @author  Remco Tolsma
12
 * @version 2.0.0
13
 * @since   1.0.0
14
 */
15
class Error extends \Exception {
16
	/**
17
	 * Error code.
18
	 *
19
	 * @var string|null
20
	 */
21
	private $error_code;
22
23
	/**
24
	 * Description.
25
	 *
26
	 * @var string|null
27
	 */
28
	private $description;
29
30
	/**
31
	 * Constructs and initializes an TargetPay error.
32
	 *
33
	 * @param string $value Value.
34
	 */
35 2
	public function __construct( $value ) {
36 2
		parent::__construct( $value );
37
38 2
		$space_position = \strpos( $value, ' ' );
39
40 2
		if ( false !== $space_position ) {
41 1
			$this->error_code  = \substr( $value, 0, $space_position );
42 1
			$this->description = \substr( $value, $space_position + 1 );
43
		}
44 2
	}
45
46
	/**
47
	 * Get code.
48
	 *
49
	 * @return string|null
50
	 */
51 2
	public function get_code() {
52 2
		return $this->error_code;
53
	}
54
55
	/**
56
	 * Set code.
57
	 *
58
	 * @param string|null $code Code.
59
	 */
60
	public function set_code( $code ) {
61
		$this->error_code = $code;
62
	}
63
64
	/**
65
	 * Get description.
66
	 *
67
	 * @return string|null
68
	 */
69
	public function get_description() {
70
		return $this->description;
71
	}
72
73
	/**
74
	 * Set description.
75
	 *
76
	 * @param string|null $description Description.
77
	 */
78
	public function set_description( $description ) {
79
		$this->description = $description;
80
	}
81
}
82