Passed
Push — master ( 4ba7a2...33d4e3 )
by Petr
08:15
created

AccountsCerts::updateCertData()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 3
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
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