Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
MalformedTitleException | |
0.00% |
0 / 12 |
|
0.00% |
0 / 5 |
42 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
getTitleText | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getErrorMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getErrorMessageParameters | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getMessageObject | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @file |
19 | */ |
20 | |
21 | namespace MediaWiki\Title; |
22 | |
23 | use Exception; |
24 | use ILocalizedException; |
25 | use MediaWiki\Message\Message; |
26 | |
27 | /** |
28 | * MalformedTitleException is thrown when a TitleParser is unable to parse a title string. |
29 | * @newable |
30 | * @since 1.23 |
31 | */ |
32 | class MalformedTitleException extends Exception implements ILocalizedException { |
33 | |
34 | /** @var string|null */ |
35 | private $titleText; |
36 | /** @var string */ |
37 | private $errorMessage; |
38 | /** @var array */ |
39 | private $errorMessageParameters; |
40 | |
41 | /** |
42 | * @stable to call |
43 | * @param string $errorMessage Localisation message describing the error (since MW 1.26) |
44 | * @param string|null $titleText The invalid title text (since MW 1.26) |
45 | * @param array $errorMessageParameters Additional parameters for the error message. |
46 | * $titleText will be appended if it's not null. (since MW 1.26) |
47 | */ |
48 | public function __construct( |
49 | $errorMessage, $titleText = null, $errorMessageParameters = [] |
50 | ) { |
51 | $this->errorMessage = $errorMessage; |
52 | $this->titleText = $titleText; |
53 | if ( $titleText !== null ) { |
54 | $errorMessageParameters[] = wfEscapeWikiText( $titleText ); |
55 | } |
56 | $this->errorMessageParameters = $errorMessageParameters; |
57 | |
58 | // Supply something useful for Exception::getMessage() to return. |
59 | $enMsg = wfMessage( $errorMessage, $errorMessageParameters ); |
60 | $enMsg->inLanguage( 'en' )->useDatabase( false ); |
61 | parent::__construct( $enMsg->text() ); |
62 | } |
63 | |
64 | /** |
65 | * @since 1.26 |
66 | * @return string|null |
67 | */ |
68 | public function getTitleText() { |
69 | return $this->titleText; |
70 | } |
71 | |
72 | /** |
73 | * @since 1.26 |
74 | * @return string |
75 | */ |
76 | public function getErrorMessage() { |
77 | return $this->errorMessage; |
78 | } |
79 | |
80 | /** |
81 | * @since 1.26 |
82 | * @return array |
83 | */ |
84 | public function getErrorMessageParameters() { |
85 | return $this->errorMessageParameters; |
86 | } |
87 | |
88 | /** |
89 | * @since 1.29 |
90 | * @return Message |
91 | */ |
92 | public function getMessageObject() { |
93 | return wfMessage( $this->getErrorMessage(), $this->getErrorMessageParameters() ); |
94 | } |
95 | } |
96 | |
97 | /** @deprecated class alias since 1.41 */ |
98 | class_alias( MalformedTitleException::class, 'MalformedTitleException' ); |