KeyGenerator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
wmc 1
eloc 4
dl 0
loc 13
ccs 1
cts 3
cp 0.3333
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 4 1
1
<?php
2
3
namespace kalanis\OAuth2;
4
5
6
/**
7
 * KeyGenerator
8
 * @package kalanis\OAuth2
9
 */
10 1
class KeyGenerator implements IKeyGenerator
11
{
12
    /** Key generator algorithm */
13
    public const ALGORITHM = 'sha256';
14
15
    /**
16
     * Generate random token
17
     * @param int $length
18
     */
19
    public function generate(int $length = 40): string
20
    {
21
        $bytes = openssl_random_pseudo_bytes($length);
22
        return hash(self::ALGORITHM, $bytes);
23
    }
24
}
25