Completed
Push — master ( 6cf2fc...de9661 )
by Roy
02:01
created

WC_Stripe_Exception   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getLocalizedMessage() 0 3 1
1
<?php
2
/**
3
 * WooCommerce Stripe Exception Class
4
 *
5
 * Extends Exception to provide additional data
6
 *
7
 * @since 4.0.2
8
 */
9
10
if ( ! defined( 'ABSPATH' ) ) {
11
	exit; // Exit if accessed directly
12
}
13
14
class WC_Stripe_Exception extends Exception {
15
16
	/** @var string sanitized/localized error message */
17
	protected $localized_message;
18
19
	/**
20
	 * Setup exception
21
	 *
22
	 * @since 4.0.2
23
	 * @param string $error_message Full response
24
	 * @param string $localized_message user-friendly translated error message
25
	 */
26
	public function __construct( $error_message = '', $localized_message = '' ) {
27
		$this->localized_message = $localized_message;
28
		parent::__construct( $error_message );
29
	}
30
31
	/**
32
	 * Returns the localized message.
33
	 *
34
	 * @since 4.0.2
35
	 * @return string
36
	 */
37
	public function getLocalizedMessage() {
38
		return $this->localized_message;
39
	}
40
}
41