Skip to content

Commit 4a57c24

Browse files
committed
Merge pull request facebookarchive#548 from DragonBe/mb_substr
GitHub Issue facebookarchive#546: Received a fatal because mb_substr was not found.
2 parents bb1e618 + 822833a commit 4a57c24

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Facebook/PseudoRandomString/PseudoRandomStringGeneratorTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,15 @@ public function validateLength($length)
4848
*
4949
* @param string $binaryData The binary data to convert to hex.
5050
* @param int $length The length of the string to return.
51+
* @throws \RuntimeException Throws an exception when multibyte support is not enabled
5152
*
5253
* @return string
5354
*/
5455
public function binToHex($binaryData, $length)
5556
{
56-
return mb_substr(bin2hex($binaryData), 0, $length);
57+
if (true !== extension_loaded('mbstring')) {
58+
throw new \RuntimeException('Multibyte support required');
59+
}
60+
return \mb_substr(\bin2hex($binaryData), 0, $length);
5761
}
5862
}

0 commit comments

Comments
 (0)