Passed
Push — master ( 658945...f0b652 )
by Petr
02:27
created

AccountsCerts   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 20
ccs 9
cts 9
cp 1
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A updateCertKeys() 0 9 3
A getCertData() 0 4 3
1
<?php
2
3
namespace kalanis\kw_auth_sources\Sources\Memory;
4
5
6
use kalanis\kw_auth_sources\Interfaces;
7
use kalanis\kw_auth_sources\Interfaces\IUserCert;
8
9
10
/**
11
 * Class AccountsCerts
12
 * @package kalanis\kw_auth_sources\Sources\Memory
13
 * Authenticate class with certificates - in memory
14
 */
15
class AccountsCerts extends Accounts implements Interfaces\IAuthCert
16
{
17
    /** @var Interfaces\IUserCert[] */
18
    protected $local = [];
19
20 1
    public function updateCertKeys(string $userName, ?string $certKey, ?string $certSalt): bool
21
    {
22 1
        foreach ($this->local as $item) {
23 1
            if ($item->getAuthName() == $userName) {
24 1
                $item->addCertInfo($certKey, $certSalt);
25 1
                return true;
26
            }
27
        }
28 1
        return false;
29
    }
30
31 2
    public function getCertData(string $userName): ?IUserCert
32
    {
33 2
        $user = $this->getDataOnly($userName);
34 2
        return ($user && ($user instanceof Interfaces\IUserCert)) ? clone $user : null;
0 ignored issues
show
introduced by
$user is always a sub-type of kalanis\kw_auth_sources\Interfaces\IUserCert.
Loading history...
35
    }
36
}
37