Algorithm   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A algorithm() 0 7 1
A name() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MiladRahimi\Jwt\Cryptography\Algorithms\Rsa;
6
7
/**
8
 * Automatic algorithm-based value generator
9
 */
10
trait Algorithm
11
{
12
    protected static string $name;
13
14
    /**
15
     * @inheritdoc
16
     */
17
    public function name(): string
18
    {
19
        return static::$name;
20
    }
21
22
    protected function algorithm(): int
23
    {
24
        return [
25
            'RS256' => OPENSSL_ALGO_SHA256,
26
            'RS384' => OPENSSL_ALGO_SHA384,
27
            'RS512' => OPENSSL_ALGO_SHA512,
28
        ][$this->name()];
29
    }
30
}
31