Completed
Push — main ( 26c7b4...5ab5c5 )
by
unknown
04:18
created

UsageException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 62
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0
rs 10
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
	private string $apiCode;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
17
18
	private array $result = [];
19
20
	private string $rawMessage;
21
22
	/**
23
	 * @since 0.1
24
	 *
25
	 * @param string $apiCode The API error code.
26
	 * @param string $message The API error message.
27
	 * @param array $result the result the exception was generated from
28
	 */
29
	public function __construct( $apiCode = '', $message = '', $result = [] ) {
30
		$this->apiCode = $apiCode;
31
		$this->result = $result;
32
		$this->rawMessage = $message;
33
		$message = 'Code: ' . $apiCode . PHP_EOL .
34
			'Message: ' . $message . PHP_EOL .
35
			'Result: ' . json_encode( $result );
36
		parent::__construct( $message, 0, null );
37
	}
38
39
	/**
40
	 * @since 0.1
41
	 */
42
	public function getApiCode(): string {
43
		return $this->apiCode;
44
	}
45
46
	/**
47
	 * @since 0.3
48
	 *
49
	 * @return mixed[]
50
	 */
51
	public function getApiResult(): array {
52
		return $this->result;
53
	}
54
55
	/**
56
	 * @since 2.3.0
57
	 */
58
	public function getRawMessage(): string {
59
		return $this->rawMessage;
60
	}
61
62
}
63