Test Failed
Push — master ( a6b51e...5fffdb )
by Gabriel
08:05
created

RandomHelper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
ccs 5
cts 5
cp 1
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generateToken() 0 6 1
A generateIdentifier() 0 5 1
1
<?php
2
3
namespace ByTIC\Hello\Utility;
4
5
/**
6
 * Class RandomHelper
7
 * @package ByTIC\Hello\Utility
8
 */
9
final class RandomHelper
10
{
11
    /** @noinspection PhpDocMissingThrowsInspection
12
     * @return mixed
13
     */
14 19
    public static function generateToken()
15
    {
16
        /** @noinspection PhpUnhandledExceptionInspection */
17 19
        $bytes = random_bytes(32);
18 19
        return base_convert(bin2hex($bytes), 16, 36);
19
    }
20
21
    /** @noinspection PhpDocMissingThrowsInspection
22
     * @return string
23
     */
24 19
    public static function generateIdentifier()
25
    {
26
        /** @noinspection PhpUnhandledExceptionInspection */
27 19
        return hash('md5', random_bytes(16));
28
    }
29
}
30