Skip to content

Commit 2dea67f

Browse files
committed
Minor cleanup
* Move test @Covers to class level * Remove docblocks that duplicate function and return param types
1 parent 049f3d4 commit 2dea67f

File tree

3 files changed

+8
-32
lines changed

3 files changed

+8
-32
lines changed

src/HOTP.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class HOTP
2323
*/
2424
public static function generateByCounter(string $key, int $counter): HOTPResult
2525
{
26-
// the counter value can be more than one byte long,
26+
// The counter value can be more than one byte long,
2727
// so we need to pack it down properly.
2828
$curCounter = [ 0, 0, 0, 0, 0, 0, 0, 0 ];
2929
for ($i = 7; $i >= 0; $i--) {
@@ -69,7 +69,7 @@ public static function generateByTime(string $key, int $window, $timestamp = fal
6969
* @param int $min the minimum window to accept before $timestamp
7070
* @param int $max the maximum window to accept after $timestamp
7171
* @param int|false $timestamp a timestamp to calculate for, defaults to time()
72-
* @return array of HOTPResult
72+
* @return HOTPResult[]
7373
*/
7474
public static function generateByTimeWindow(string $key, int $window, int $min = -1, int $max = 1, $timestamp = false): array
7575
{

src/HOTPResult.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class HOTPResult
2222
/**
2323
* Build an HOTP Result
2424
* @param string $value the value to construct with
25-
* @codeCoverageIgnore
2625
*/
2726
public function __construct(string $value)
2827
{
@@ -32,7 +31,6 @@ public function __construct(string $value)
3231

3332
/**
3433
* Returns the string version of the HOTP
35-
* @return string
3634
*/
3735
public function toString(): string
3836
{
@@ -41,7 +39,6 @@ public function toString(): string
4139

4240
/**
4341
* Returns the hex version of the HOTP
44-
* @return string
4542
*/
4643
public function toHex(): string
4744
{
@@ -53,7 +50,6 @@ public function toHex(): string
5350

5451
/**
5552
* Returns the decimal version of the HOTP
56-
* @return int
5753
*/
5854
public function toDec(): int
5955
{

tests/HOTPTest.php

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
* @copyright 2020
1010
* @license BSD-3-Clause
1111
* @version 1.0
12+
*
13+
* @covers \jakobo\HOTP\HOTP
14+
* @covers \jakobo\HOTP\HOTPResult
1215
*/
1316
class HOTPTest extends TestCase
1417
{
@@ -100,17 +103,7 @@ public function provideHOTP(): array
100103
];
101104
}
102105

103-
/**
104-
* @param int $seed
105-
* @param array $result
106-
*
107-
* @covers \jakobo\HOTP\HOTP::generateByCounter
108-
* @covers \jakobo\HOTP\HOTPResult::toString
109-
* @covers \jakobo\HOTP\HOTPResult::toHex
110-
* @covers \jakobo\HOTP\HOTPResult::toDec
111-
* @covers \jakobo\HOTP\HOTPResult::toHOTP
112-
* @dataProvider provideHOTP
113-
*/
106+
/** @dataProvider provideHOTP */
114107
public function testHOTP(int $seed, array $result): void
115108
{
116109
$hotp = HOTP::generateByCounter(self::KEY, $seed);
@@ -147,14 +140,7 @@ public function provideTOTP(): array
147140
];
148141
}
149142

150-
/**
151-
* @param string $seed
152-
* @param string $result
153-
*
154-
* @covers \jakobo\HOTP\HOTP::generateByTime
155-
* @covers \jakobo\HOTP\HOTPResult::toHOTP
156-
* @dataProvider provideTOTP
157-
*/
143+
/** @dataProvider provideTOTP */
158144
public function testTOTP(string $seed, string $result): void
159145
{
160146
$totp = HOTP::generateByTime(self::KEY, 30, $seed);
@@ -183,13 +169,7 @@ public function provideGenerateByTimeWindow(): array
183169
];
184170
}
185171

186-
/**
187-
* @param string $seed
188-
* @param string[] $result
189-
* @covers \jakobo\HOTP\HOTP::generateByTimeWindow
190-
* @covers \jakobo\HOTP\HOTPResult::toHOTP
191-
* @dataProvider provideGenerateByTimeWindow
192-
*/
172+
/** @dataProvider provideGenerateByTimeWindow */
193173
public function testGenerateByTimeWindow(string $seed, array $result): void
194174
{
195175
$results = HOTP::generateByTimeWindow(

0 commit comments

Comments
 (0)