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::cekForEncryption()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 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