Skip to content

Commit 7e37125

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

3 files changed

Lines changed: 8 additions & 36 deletions

File tree

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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ class HOTPResult
1919
protected $decimal;
2020
protected $hex;
2121

22-
/**
23-
* Build an HOTP Result
24-
* @param string $value the value to construct with
25-
* @codeCoverageIgnore
26-
*/
2722
public function __construct(string $value)
2823
{
2924
// store raw
@@ -32,7 +27,6 @@ public function __construct(string $value)
3227

3328
/**
3429
* Returns the string version of the HOTP
35-
* @return string
3630
*/
3731
public function toString(): string
3832
{
@@ -41,7 +35,6 @@ public function toString(): string
4135

4236
/**
4337
* Returns the hex version of the HOTP
44-
* @return string
4538
*/
4639
public function toHex(): string
4740
{
@@ -53,7 +46,6 @@ public function toHex(): string
5346

5447
/**
5548
* Returns the decimal version of the HOTP
56-
* @return int
5749
*/
5850
public function toDec(): int
5951
{

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)