RandomHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 4
c 1
b 0
f 1
dl 0
loc 19
rs 10
ccs 5
cts 5
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generateToken() 0 5 1
A generateIdentifier() 0 4 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 20
    public static function generateToken()
15
    {
16
        /** @noinspection PhpUnhandledExceptionInspection */
17 20
        $bytes = random_bytes(32);
18 20
        return base_convert(bin2hex($bytes), 16, 36);
19
    }
20
21
    /** @noinspection PhpDocMissingThrowsInspection
22
     * @return string
23
     */
24 20
    public static function generateIdentifier()
25
    {
26
        /** @noinspection PhpUnhandledExceptionInspection */
27 20
        return hash('md5', random_bytes(16));
28
    }
29
}
30