Passed
Push — master ( 4ba7a2...33d4e3 )
by Petr
08:15
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 getCertData() 0 4 3
A updateCertData() 0 9 3
1
<?php
2
3
namespace kalanis\kw_auth_sources\Sources\Memory;
4
5
6
use kalanis\kw_accounts\Interfaces;
7
8
9
/**
10
 * Class AccountsCerts
11
 * @package kalanis\kw_auth_sources\Sources\Memory
12
 * Authenticate class with certificates - in memory
13
 */
14
class AccountsCerts extends Accounts implements Interfaces\IAuthCert
15
{
16
    /** @var Interfaces\IUserCert[] */
17
    protected $local = [];
18
19 1
    public function updateCertData(string $userName, ?string $certKey, ?string $certSalt): bool
20
    {
21 1
        foreach ($this->local as $item) {
22 1
            if ($item->getAuthName() == $userName) {
23 1
                $item->updateCertInfo($certKey, $certSalt);
24 1
                return true;
25
            }
26
        }
27 1
        return false;
28
    }
29
30 2
    public function getCertData(string $userName): ?Interfaces\ICert
31
    {
32 2
        $user = $this->getDataOnly($userName);
33 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_accounts\Interfaces\IUserCert.
Loading history...
34
    }
35
}
36