Skip to content

Commit 7d44a28

Browse files
committed
Add timeStep accessor functions
1 parent bcb125e commit 7d44a28

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/OTP/TOTP.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,32 @@ protected function getDefaultCounter()
3636
return time();
3737
}
3838

39+
/**
40+
* Gets current Time Step value
41+
*
42+
* @return int
43+
*/
44+
public function getTimeStep()
45+
{
46+
return $this->timeStep;
47+
}
48+
49+
/**
50+
* Sets Time Step value
51+
*
52+
* @param int $step
53+
* @return int
54+
* @throws Exception
55+
*/
56+
public function setTimeStep($step)
57+
{
58+
if (! is_int($step) || ! $step > 0) {
59+
throw new Exception('Invalid time step');
60+
}
61+
62+
return $this->timeStep = $step;
63+
}
64+
3965
/**
4066
* Apply on counter before generation password
4167
*

0 commit comments

Comments
 (0)