Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5969520
FixedTimeLimit.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
FixedTimeLimit.php
View Options
<?php
namespace
Eris\Shrinker
;
class
FixedTimeLimit
implements
TimeLimit
{
private
$maximumIntervalLength
;
private
$clock
;
private
$startOfTheInterval
;
public
static
function
realTime
(
$maximumIntervalLength
)
{
return
new
self
(
$maximumIntervalLength
,
'time'
);
}
/**
* @param int $maximumIntervalLength in seconds
*/
public
function
__construct
(
$maximumIntervalLength
,
callable
$clock
)
{
$this
->
maximumIntervalLength
=
$maximumIntervalLength
;
$this
->
clock
=
$clock
;
}
public
function
start
()
{
$this
->
startOfTheInterval
=
call_user_func
(
$this
->
clock
);
}
public
function
hasBeenReached
()
{
$actualIntervalLength
=
call_user_func
(
$this
->
clock
)
-
$this
->
startOfTheInterval
;
return
$actualIntervalLength
>=
$this
->
maximumIntervalLength
;
}
public
function
__toString
()
{
$actualIntervalLength
=
call_user_func
(
$this
->
clock
)
-
$this
->
startOfTheInterval
;
return
"{$actualIntervalLength}s elapsed of {$this->maximumIntervalLength}s"
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 13:49 (2 d, 3 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
af/f1/fcff8ccaeb0a8b4534e231dc0a5c
Default Alt Text
FixedTimeLimit.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment