Completed
Push — master ( 2994aa...19d116 )
by Patrick
08:28
created

RandomStringGeneratorTrait::binToHex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
namespace Dropbox\Security;
3
4
trait RandomStringGeneratorTrait
5
{
6
    /**
7
     * Converts binary data to hexadecimal of given length
8
     *
9
     * @param string $binaryData The binary data to convert to hex.
10
     * @param int    $length     The length of the string to return.
11
     *
12
     * @throws \RuntimeException Throws an exception when multibyte support is not enabled
13
     *
14
     * @return string
15
     */
16
    public function binToHex($binaryData, $length)
17
    {
18
        return substr(bin2hex($binaryData), 0, $length);
19
    }
20
}
21