Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/OTP/TOTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,32 @@ protected function getDefaultCounter()
return time();
}

/**
* Gets current Time Step value
*
* @return int
*/
public function getTimeStep()
{
return $this->timeStep;
}

/**
* Sets Time Step value
*
* @param int $step
* @return int
* @throws Exception
*/
public function setTimeStep($step)
{
if (! is_int($step) || ! $step > 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't configure a style linter, but would like to keep it PSR-12 compatible, so could we format this differently?
Also I don't thing not and greater than should be combined because is simpler to use lower than

Suggested change
if (! is_int($step) || ! $step > 0) {
if (!is_int($step) || $step < 1) {

throw new Exception('Invalid time step');
}

return $this->timeStep = $step;
}

/**
* Apply on counter before generation password
*
Expand Down