Passed
Push — master ( fbb13e...d759f2 )
by Milad
02:55
created

Algorithm   A

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