GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Branch php72 (880eb0)
by Joni
05:58
created

RandomCEK   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 18
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A cekForEncryption() 0 7 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\JWX\JWE\KeyAlgorithm\Feature;
6
7
/**
8
 * Trait for key algorithms employing random CEK generation.
9
 */
10
trait RandomCEK
11
{
12
    /**
13
     * Generate a random content encryption key.
14
     *
15
     * @param int $length Key length in bytes
16
     *
17
     * @throws \RuntimeException
18
     *
19
     * @return string
20
     */
21 3
    public function cekForEncryption(int $length): string
22
    {
23 3
        $ret = openssl_random_pseudo_bytes($length);
24 3
        if (false === $ret) {
25 1
            throw new \RuntimeException('openssl_random_pseudo_bytes() failed.');
26
        }
27 2
        return $ret;
28
    }
29
}
30