Skip to content

Commit 8a93780

Browse files
Apply suggestions from code review
Co-authored-by: John Paul E. Balandan, CPA <[email protected]>
1 parent b8722d6 commit 8a93780

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

system/Helpers/text_helper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ function reduce_multiples(string $str, string $character = ',', bool $trim = fal
545545
*
546546
* Useful for generating passwords or hashes.
547547
*
548-
* @param string $type Type of random string. basic, alpha, alnum, numeric, nozero, md5, sha1, and crypto
548+
* @param string $type Type of random string: alpha, alnum, numeric, nozero, or crypto
549549
* @param int $len Number of characters
550550
*/
551551
function random_string(string $type = 'alnum', int $len = 8): string
@@ -587,7 +587,8 @@ function random_string(string $type = 'alnum', int $len = 8): string
587587
}
588588

589589
throw new InvalidArgumentException(
590-
'You must set a valid type to the first parameter when you use `random_string`.',
590+
sprintf('Invalid type "%s". Accepted types: alpha, alnum, numeric, nozero, or crypto.'),
591+
$type,
591592
);
592593
}
593594
}

tests/system/Helpers/TextHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function testRandomStringWithUnsupportedType(): void
151151
{
152152
$this->expectException(InvalidArgumentException::class);
153153
$this->expectExceptionMessage(
154-
'You must set a valid type to the first parameter when you use `random_string`.',
154+
'Invalid type "basic". Accepted types: alpha, alnum, numeric, nozero, or crypto.',
155155
);
156156

157157
random_string('basic');

0 commit comments

Comments
 (0)