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
Push — master ( 6b69a8...372506 )
by Joni
03:38
created

RandomCEK   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
dl 0
loc 19
ccs 6
cts 7
cp 0.8571
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A cekForEncryption() 0 10 3
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 3
    public function cekForEncryption(int $length): string
20
    {
21 3
        if ($length < 1) {
22 1
            throw new \InvalidArgumentException('Length must be greater than 0.');
23
        }
24 2
        $ret = openssl_random_pseudo_bytes($length);
25 2
        if (false === $ret) {
26
            throw new \RuntimeException('openssl_random_pseudo_bytes() failed.');
27
        }
28 2
        return $ret;
29
    }
30
}
31