Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace MediaWiki\Extension\Translate\MessageProcessing; |
5 | |
6 | /** |
7 | * Interface that key-mangling classes must implement. Mangling is done to: |
8 | * - converting characters which would be invalid in titles to something valid |
9 | * - prefixing a set of messages to avoid conflicts when sharing a namespace |
10 | * with multiple message groups. |
11 | * |
12 | * The operations have to be reversible so that |
13 | * x equals unmangle( mangle( x ) ). |
14 | * |
15 | * @author Niklas Laxström |
16 | * @license GPL-2.0-or-later |
17 | */ |
18 | interface StringMangler { |
19 | /** General way to pass configuration to the mangler. */ |
20 | public function setConf( array $configuration ): void; |
21 | |
22 | /** |
23 | * Match strings against a pattern. |
24 | * |
25 | * If string matches, mangle() prefixes the key. |
26 | */ |
27 | public function matches( string $key ): bool; |
28 | |
29 | /** Mangle a string. */ |
30 | public function mangle( string $key ): string; |
31 | |
32 | /** |
33 | * Mangle a list of strings. |
34 | * |
35 | * @param string[] $list |
36 | * @return string[] |
37 | */ |
38 | public function mangleList( array $list ): array; |
39 | |
40 | /** |
41 | * Mangle the keys of an array. |
42 | * |
43 | * @param array<string,mixed> $array |
44 | * @return array<string,mixed> |
45 | */ |
46 | public function mangleArray( array $array ): array; |
47 | |
48 | /** Reverse mangling of a string. */ |
49 | public function unmangle( string $key ): string; |
50 | |
51 | /** |
52 | * Reverse mangling a list of strings. |
53 | * |
54 | * @param string[] $list |
55 | * @return string[] |
56 | */ |
57 | public function unmangleList( array $list ): array; |
58 | |
59 | /** |
60 | * Reverse mangling of the keys of an array. |
61 | * |
62 | * @param array<string,mixed> $array |
63 | * @return array<string,mixed> |
64 | */ |
65 | public function unmangleArray( array $array ): array; |
66 | } |