Completed
Push — main ( d84a15...26c7b4 )
by
unknown
04:34
created

UsageException::getRawMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Addwiki\Mediawiki\Api\Client;
4
5
use Exception;
6
7
/**
8
 * Class representing a Mediawiki Api UsageException
9
 *
10
 * @since 0.1
11
 *
12
 * @author Addshore
13
 */
14
class UsageException extends Exception {
15
16
	/**
17
	 * @var string
18
	 */
19
	private $apiCode;
20
21
	/**
22
	 * @var array
23
	 */
24
	private $result = [];
25
26
	/**
27
	 * @var string
28
	 */
29
	private $rawMessage;
30
31
	/**
32
	 * @since 0.1
33
	 *
34
	 * @param string $apiCode The API error code.
35
	 * @param string $message The API error message.
36
	 * @param array $result the result the exception was generated from
37
	 */
38
	public function __construct( $apiCode = '', $message = '', $result = [] ) {
39
		$this->apiCode = $apiCode;
40
		$this->result = $result;
41
		$this->rawMessage = $message;
42
		$message = 'Code: ' . $apiCode . PHP_EOL .
43
			'Message: ' . $message . PHP_EOL .
44
			'Result: ' . json_encode( $result );
45
		parent::__construct( $message, 0, null );
46
	}
47
48
	/**
49
	 * @since 0.1
50
	 *
51
	 * @return string
52
	 */
53
	public function getApiCode() {
54
		return $this->apiCode;
55
	}
56
57
	/**
58
	 * @since 0.3
59
	 *
60
	 * @return array
61
	 */
62
	public function getApiResult() {
63
		return $this->result;
64
	}
65
66
	/**
67
	 * @since 2.3.0
68
	 *
69
	 * @return string
70
	 */
71
	public function getRawMessage() {
72
		return $this->rawMessage;
73
	}
74
75
}
76