Algorithm   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A keySize() 0 7 1
A name() 0 3 1
A algorithm() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MiladRahimi\Jwt\Cryptography\Algorithms\Ecdsa;
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
            'ES256' => OPENSSL_ALGO_SHA256,
26
            'ES256K' => OPENSSL_ALGO_SHA256,
27
            'ES384' => OPENSSL_ALGO_SHA512,
28
        ][$this->name()];
29
    }
30
31
    protected function keySize(): int
32
    {
33
        return [
34
            'ES256' => 256,
35
            'ES256K' => 256,
36
            'ES384' => 384,
37
        ][static::$name];
38
    }
39
}
40