Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ReadableNumericSerialMapping | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getSerialIdForIndex | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\User\TempUser; |
| 4 | |
| 5 | /** |
| 6 | * Simple serial mapping for ASCII decimal numbers with hyphens for readability |
| 7 | * |
| 8 | * @since 1.44 |
| 9 | */ |
| 10 | class ReadableNumericSerialMapping implements SerialMapping { |
| 11 | private readonly int $offset; |
| 12 | |
| 13 | public function __construct( array $config ) { |
| 14 | $this->offset = $config['offset'] ?? 0; |
| 15 | } |
| 16 | |
| 17 | public function getSerialIdForIndex( int $index ): string { |
| 18 | $mapped = (string)( $index + $this->offset ); |
| 19 | return rtrim( chunk_split( $mapped, 5, '-' ), '-' ); |
| 20 | } |
| 21 | } |