summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorScott <scott@paragonie.com>2017-05-04 00:53:33 -0400
committerGitHub <noreply@github.com>2017-05-04 00:53:33 -0400
commit38da9453f7e931ba54d96c385891d159d8deeed5 (patch)
tree5ebe63575aa431feb527e39bc7136b4a2ed140a7 /src
parent34838b89a29c0965d3ef790105f11d151951a87b (diff)
parentbff1419d82fb1030ee2f88eb3a746f9facbe9f50 (diff)
downloadconstant_time_encoding-master.zip
constant_time_encoding-master.tar.gz
constant_time_encoding-master.tar.bz2
Merge pull request #8 from Inkeliz/masterHEADorigin/masterorigin/HEADmaster
Duplicated code
Diffstat (limited to 'src')
-rw-r--r--src/Binary.php10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/Binary.php b/src/Binary.php
index 03476db..92bd9e3 100644
--- a/src/Binary.php
+++ b/src/Binary.php
@@ -69,16 +69,12 @@ abstract class Binary
int $start = 0,
$length = null
): string {
- if (\function_exists('mb_substr')) {
- // $length calculation above might result in a 0-length string
- if ($length === 0) {
- return '';
- }
- return \mb_substr($str, $start, $length, '8bit');
- }
if ($length === 0) {
return '';
}
+ if (\function_exists('mb_substr')) {
+ return \mb_substr($str, $start, $length, '8bit');
+ }
// Unlike mb_substr(), substr() doesn't accept NULL for length
if ($length !== null) {
return \substr($str, $start, $length);