Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 16 |
CRAP | |
0.00% |
0 / 1 |
TitleFactory | |
0.00% |
0 / 16 |
|
0.00% |
0 / 16 |
272 | |
0.00% |
0 / 1 |
newFromDBkey | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
newFromLinkTarget | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
castFromLinkTarget | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
newFromPageIdentity | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
castFromPageIdentity | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
newFromPageReference | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
castFromPageReference | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
newFromText | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
newFromTextThrow | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
newFromURL | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
newFromID | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
newFromRow | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
makeTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
makeTitleSafe | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
newMainPage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
newTitleArrayFromResult | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Factory for creating Title objects without static coupling. |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public License along |
16 | * with this program; if not, write to the Free Software Foundation, Inc., |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
18 | * http://www.gnu.org/copyleft/gpl.html |
19 | * |
20 | * @file |
21 | */ |
22 | |
23 | namespace MediaWiki\Title; |
24 | |
25 | use MediaWiki\Linker\LinkTarget; |
26 | use MediaWiki\Page\PageIdentity; |
27 | use MediaWiki\Page\PageReference; |
28 | use MessageLocalizer; |
29 | use Wikimedia\Rdbms\IResultWrapper; |
30 | |
31 | /** |
32 | * Creates Title objects. |
33 | * |
34 | * For now, there is nothing interesting in this class. It is meant for preventing static Title |
35 | * methods causing problems in unit tests. |
36 | * |
37 | * @since 1.35 |
38 | */ |
39 | class TitleFactory { |
40 | |
41 | /** |
42 | * @see Title::newFromDBkey |
43 | * @param string $key |
44 | * @return Title|null |
45 | */ |
46 | public function newFromDBkey( $key ): ?Title { |
47 | return Title::newFromDBkey( $key ); |
48 | } |
49 | |
50 | /** |
51 | * @see Title::newFromLinkTarget |
52 | * @param LinkTarget $linkTarget |
53 | * @param string $forceClone |
54 | * @return Title |
55 | */ |
56 | public function newFromLinkTarget( LinkTarget $linkTarget, $forceClone = '' ): Title { |
57 | return Title::newFromLinkTarget( $linkTarget, $forceClone ); |
58 | } |
59 | |
60 | /** |
61 | * @see Title::castFromLinkTarget |
62 | * @param LinkTarget|null $linkTarget |
63 | * @return Title|null |
64 | */ |
65 | public function castFromLinkTarget( ?LinkTarget $linkTarget ): ?Title { |
66 | return Title::castFromLinkTarget( $linkTarget ); |
67 | } |
68 | |
69 | /** |
70 | * @see Title::newFromPageIdentity |
71 | * @since 1.41 |
72 | * @param PageIdentity $pageIdentity |
73 | * @return Title |
74 | */ |
75 | public function newFromPageIdentity( PageIdentity $pageIdentity ): Title { |
76 | return Title::newFromPageIdentity( $pageIdentity ); |
77 | } |
78 | |
79 | /** |
80 | * @see Title::castFromPageIdentity |
81 | * @since 1.36 |
82 | * @param PageIdentity|null $pageIdentity |
83 | * @return Title|null |
84 | */ |
85 | public function castFromPageIdentity( ?PageIdentity $pageIdentity ): ?Title { |
86 | return Title::castFromPageIdentity( $pageIdentity ); |
87 | } |
88 | |
89 | /** |
90 | * @see Title::newFromPageReference |
91 | * @since 1.41 |
92 | * @param PageReference $pageReference |
93 | * @return Title |
94 | */ |
95 | public function newFromPageReference( PageReference $pageReference ): Title { |
96 | return Title::newFromPageReference( $pageReference ); |
97 | } |
98 | |
99 | /** |
100 | * @see Title::castFromPageReference |
101 | * @since 1.37 |
102 | * @param PageReference|null $pageReference |
103 | * @return Title|null |
104 | */ |
105 | public function castFromPageReference( ?PageReference $pageReference ): ?Title { |
106 | return Title::castFromPageReference( $pageReference ); |
107 | } |
108 | |
109 | /** |
110 | * @see Title::newFromText |
111 | * @param string|int|null $text |
112 | * @param int $defaultNamespace |
113 | * @return Title|null |
114 | * @throws \InvalidArgumentException |
115 | */ |
116 | public function newFromText( $text, $defaultNamespace = NS_MAIN ): ?Title { |
117 | return Title::newFromText( $text, $defaultNamespace ); |
118 | } |
119 | |
120 | /** |
121 | * @see Title::newFromTextThrow |
122 | * @param string $text |
123 | * @param int $defaultNamespace |
124 | * @return Title |
125 | * @throws MalformedTitleException |
126 | */ |
127 | public function newFromTextThrow( $text, $defaultNamespace = NS_MAIN ): Title { |
128 | return Title::newFromTextThrow( $text, $defaultNamespace ); |
129 | } |
130 | |
131 | /** |
132 | * @see Title::newFromURL |
133 | * @param string $url |
134 | * @return Title|null |
135 | */ |
136 | public function newFromURL( $url ): ?Title { |
137 | return Title::newFromURL( $url ); |
138 | } |
139 | |
140 | /** |
141 | * @see Title::newFromID |
142 | * @param int $id |
143 | * @param int $flags |
144 | * @return Title|null |
145 | */ |
146 | public function newFromID( $id, $flags = 0 ): ?Title { |
147 | return Title::newFromID( $id, $flags ); |
148 | } |
149 | |
150 | /** |
151 | * @see Title::newFromRow |
152 | * @param \stdClass $row |
153 | * @return Title |
154 | */ |
155 | public function newFromRow( $row ): Title { |
156 | return Title::newFromRow( $row ); |
157 | } |
158 | |
159 | /** |
160 | * @see Title::makeTitle |
161 | * @param int $ns |
162 | * @param string $title |
163 | * @param string $fragment |
164 | * @param string $interwiki |
165 | * @return Title |
166 | */ |
167 | public function makeTitle( $ns, $title, $fragment = '', $interwiki = '' ): Title { |
168 | return Title::makeTitle( $ns, $title, $fragment, $interwiki ); |
169 | } |
170 | |
171 | /** |
172 | * @see Title::makeTitleSafe |
173 | * @param int $ns |
174 | * @param string $title |
175 | * @param string $fragment |
176 | * @param string $interwiki |
177 | * @return Title|null |
178 | */ |
179 | public function makeTitleSafe( $ns, $title, $fragment = '', $interwiki = '' ): ?Title { |
180 | return Title::makeTitleSafe( $ns, $title, $fragment, $interwiki ); |
181 | } |
182 | |
183 | /** |
184 | * @see Title::newMainPage |
185 | * @param MessageLocalizer|null $localizer |
186 | * @return Title |
187 | */ |
188 | public function newMainPage( MessageLocalizer $localizer = null ): Title { |
189 | return Title::newMainPage( $localizer ); |
190 | } |
191 | |
192 | /** |
193 | * @since 1.42 |
194 | * @param IResultWrapper $result |
195 | * @return TitleArrayFromResult |
196 | */ |
197 | public function newTitleArrayFromResult( IResultWrapper $result ) { |
198 | return new TitleArrayFromResult( $result ); |
199 | } |
200 | |
201 | } |
202 | |
203 | /** @deprecated class alias since 1.41 */ |
204 | class_alias( TitleFactory::class, 'TitleFactory' ); |