Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7405405
Sequential.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
Sequential.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Phan\Library\Hasher
;
use
Phan\Library\Hasher
;
/**
* Hasher implementation mapping keys to sequential groups (first key to 0, second key to 1, looping back to 0)
* getGroup() is called exactly once on each string to be hashed.
*/
class
Sequential
implements
Hasher
{
/** @var int an incrementing counter mapping the first key to group 0, the second key to 1, etc. (modulo group_count) */
protected
$counter
;
/** @var int the total number of groups. */
protected
$group_count
;
public
function
__construct
(
int
$group_count
)
{
$this
->
counter
=
1
;
$this
->
group_count
=
$group_count
;
}
/**
* @param string $key (Used by sibling class Consistent) (@phan-unused-param)
* @return int - an integer between 0 and $this->group_count - 1, inclusive
*/
public
function
getGroup
(
string
$key
):
int
{
return
(
$this
->
counter
++)
%
$this
->
group_count
;
}
/**
* Resets counter
*/
public
function
reset
():
void
{
$this
->
counter
=
1
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 19:51 (1 d, 4 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e0/69/e897641f09fd9df5c8079edb70a6
Default Alt Text
Sequential.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment