Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/HOTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ public function verify(string $otp, null|int $counter = null, null|int $window =
return $this->verifyOtpWithWindow($otp, $counter, $window);
}

public function setCounter(int $counter): void
public function setCounter(int $counter): static
{
$this->setParameter('counter', $counter);

return $this;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/HOTPInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ public static function create(
int $digits = 6
): self;

public function setCounter(int $counter): void;
public function setCounter(int $counter): static;
}
10 changes: 5 additions & 5 deletions src/OTPInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public static function generate(): self;
/**
* @param non-empty-string $secret
*/
public function setSecret(string $secret): void;
public function setSecret(string $secret): static;

public function setDigits(int $digits): void;
public function setDigits(int $digits): static;

/**
* @param non-empty-string $digest
*/
public function setDigest(string $digest): void;
public function setDigest(string $digest): static;

/**
* @return non-empty-string Return the OTP at the specified timestamp
Expand All @@ -57,7 +57,7 @@ public function getSecret(): string;
/**
* @param non-empty-string $label The label of the OTP
*/
public function setLabel(string $label): void;
public function setLabel(string $label): static;

/**
* @return non-empty-string|null The label of the OTP
Expand All @@ -72,7 +72,7 @@ public function getIssuer(): ?string;
/**
* @param non-empty-string $issuer
*/
public function setIssuer(string $issuer): void;
public function setIssuer(string $issuer): static;

/**
* @return bool If true, the issuer will be added as a parameter in the provisioning URI
Expand Down
20 changes: 15 additions & 5 deletions src/ParameterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,23 @@ public function getLabel(): null|string
return $this->label;
}

public function setLabel(string $label): void
public function setLabel(string $label): static
{
$this->setParameter('label', $label);

return $this;
}

public function getIssuer(): null|string
{
return $this->issuer;
}

public function setIssuer(string $issuer): void
public function setIssuer(string $issuer): static
{
$this->setParameter('issuer', $issuer);

return $this;
}

public function isIssuerIncludedAsParameter(): bool
Expand Down Expand Up @@ -128,19 +132,25 @@ public function setParameter(string $parameter, mixed $value): void
}
}

public function setSecret(string $secret): void
public function setSecret(string $secret): static
{
$this->setParameter('secret', $secret);

return $this;
}

public function setDigits(int $digits): void
public function setDigits(int $digits): static
{
$this->setParameter('digits', $digits);

return $this;
}

public function setDigest(string $digest): void
public function setDigest(string $digest): static
{
$this->setParameter('algorithm', $digest);

return $this;
}

/**
Expand Down
8 changes: 6 additions & 2 deletions src/TOTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,18 @@ public function getProvisioningUri(): string
return $this->generateURI('totp', $params);
}

public function setPeriod(int $period): void
public function setPeriod(int $period): static
{
$this->setParameter('period', $period);

return $this;
}

public function setEpoch(int $epoch): void
public function setEpoch(int $epoch): static
{
$this->setParameter('epoch', $epoch);

return $this;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/TOTPInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public static function create(
int $digits = self::DEFAULT_DIGITS
): self;

public function setPeriod(int $period): void;
public function setPeriod(int $period): static;

public function setEpoch(int $epoch): void;
public function setEpoch(int $epoch): static;

/**
* Return the TOTP at the current time.
Expand Down