Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
PageHashGenerate
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getPageHash
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace WikimediaEvents\PageSplitter;
4
5/**
6 * @license GPL-2.0-or-later
7 */
8class PageHashGenerate {
9
10    /**
11     * Get hash of a page ID as a float between 0.0 (inclusive) and 1.0 (non-inclusive).
12     *
13     * @param int $pageId
14     * @return float
15     */
16    public function getPageHash( int $pageId ): float {
17        return intval( substr( md5( (string)$pageId ), 0, 6 ), 16 ) / ( 0xffffff + 1 );
18    }
19
20}