MediaWiki
REL1_39
FilteredRadixSerialMapping.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\User\TempUser
;
4
5
use
ArrayUtils
;
6
17
class
FilteredRadixSerialMapping
implements
SerialMapping
{
19
private
$radix;
20
22
private
$badIndexes;
23
25
private
$uppercase;
26
30
public
function
__construct
( $config ) {
31
$this->radix = $config[
'radix'
] ?? 10;
32
$this->badIndexes = $config[
'badIndexes'
] ?? [];
33
$this->uppercase = $config[
'uppercase'
] ??
false
;
34
}
35
36
public
function
getSerialIdForIndex
(
int
$index ): string {
37
$index = $this->adjustID( $index );
38
return \Wikimedia\base_convert( (
string
)$index, 10, $this->radix, 1, !$this->uppercase );
39
}
40
48
private
function
adjustID(
int
$id ): int {
49
$pos =
ArrayUtils
::findLowerBound(
50
function ( $i ) {
51
return
$this->badIndexes[$i];
52
},
53
count( $this->badIndexes ),
54
static
function
( $a, $b ) {
55
return
$a <=> $b;
56
},
57
$id
58
);
59
return
$pos ===
false
? $id : $id + $pos + 1;
60
}
61
}
ArrayUtils
A collection of static methods to play with arrays.
Definition
ArrayUtils.php:28
MediaWiki\User\TempUser\FilteredRadixSerialMapping
Since "base" is an overused term in class names and mostly means something else, we will call the bas...
Definition
FilteredRadixSerialMapping.php:17
MediaWiki\User\TempUser\FilteredRadixSerialMapping\getSerialIdForIndex
getSerialIdForIndex(int $index)
Definition
FilteredRadixSerialMapping.php:36
MediaWiki\User\TempUser\FilteredRadixSerialMapping\__construct
__construct( $config)
Definition
FilteredRadixSerialMapping.php:30
MediaWiki\User\TempUser\SerialMapping
Interface for integer to string mappings for temporary user autocreation.
Definition
SerialMapping.php:10
MediaWiki\User\TempUser
Definition
CreateStatus.php:3
includes
user
TempUser
FilteredRadixSerialMapping.php
Generated on Tue Sep 17 2024 07:36:57 for MediaWiki by
1.10.0