LastInstance   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 27
ccs 13
cts 13
cp 1
rs 10
wmc 11

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 21 11
1
<?php
2
3
namespace kalanis\kw_auth_sources\Access\SourcesAdapters;
4
5
6
use kalanis\kw_accounts\AccountsException;
7
use kalanis\kw_accounts\Interfaces;
8
9
10
/**
11
 * Class LastInstance
12
 * @package kalanis\kw_auth_sources\Access\SourcesAdapters
13
 * Set that by its last known instance
14
 */
15
class LastInstance extends AAdapter
16
{
17
    /**
18
     * @param mixed ...$params
19
     * @throws AccountsException
20
     */
21 2
    public function __construct(...$params)
22
    {
23 2
        foreach ($params as $param) {
24 2
            if (is_object($param)) {
25 2
                if ($param instanceof Interfaces\IAuth) {
26 2
                    $this->auth = $param;
27
                }
28 2
                if ($param instanceof Interfaces\IProcessAccounts) {
29 2
                    $this->accounts = $param;
30
                }
31 2
                if ($param instanceof Interfaces\IProcessClasses) {
32 1
                    $this->classes = $param;
33
                }
34 2
                if ($param instanceof Interfaces\IProcessGroups) {
35 2
                    $this->groups = $param;
36
                }
37
            }
38
        }
39
40 2
        if (!($this->auth && $this->accounts && $this->classes && $this->groups)) {
41 1
            throw new AccountsException('You must set all necessary classes in the params first!');
42
        }
43 1
    }
44
}
45