blob: fc6c19c47e3fa0132f77e453916b3edfa0acea3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<?php
declare( strict_types = 1 );
namespace MediaWiki\Extension\Translate\Utilities;
/**
* Create unique placeholders that can be used when parsing (wiki)text.
* @author Niklas Laxström
* @license GPL-2.0-or-later
* @since 2020.07
*/
class ParsingPlaceholderFactory {
private $i = 0;
/** Return value is guaranteed to only contain [a-zA-Z0-9\x7f] */
public function make(): string {
return "\x7fUNIQ" .
dechex( mt_rand( 0, 0x7fffffff ) ) .
dechex( mt_rand( 0, 0x7fffffff ) ) .
'-' .
$this->i++;
}
}
class_alias( ParsingPlaceholderFactory::class, '\MediaWiki\Extensions\Translate\ParsingPlaceholderFactory' );
|