Completed
Push — master ( 7ad915...1f6acb )
by Park Jong-Hun
03:16
created

AuthManager::setAccountManagerConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace App\Auth;
4
5
class AuthManager
6
{
7
8
    private $config = [];
9
10
    private $accountManagerConfig = [];
11
    private $loginManagerConfig = [];
12
13
    private function __construct()
14
    {
15
    }
16
17
    /**
18
     * @return self
19
     */
20
    public static function getInstance()
21
    {
22
        static $instance = null;
23
24
        if ($instance === null) {
25
            $instance = new self();
26
        }
27
28
        return $instance;
29
    }
30
31
32
    public function setConfig(array $config)
33
    {
34
        $this->config = $config;
35
    }
36
37
    public function setAccountManagerConfig(array $config)
38
    {
39
        $this->accountManagerConfig = $config;
40
    }
41
42
    public function setLoginManagerConfig(array $config)
43
    {
44
        $this->loginManagerConfig = $config;
45
    }
46
47
48
    public function isDefaultAllow()
49
    {
50
        return $this->config['defaultAllow'];
51
    }
52
53
    /**
54
     * @return AccountManagerInterface
55
     */
56 View Code Duplication
    public function getDefaultAccountManager()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
57
    {
58
        $defaultAccountManagerConfig = $this->accountManagerConfig[$this->config['defaultAccountManager']];
59
60
        $className = $defaultAccountManagerConfig['class'];
61
        $settings = $defaultAccountManagerConfig['settings'];
62
63
        return new $className($settings);
64
    }
65
66
    /**
67
     * @return LoginManagerInterface
68
     */
69 View Code Duplication
    public function getDefaultLoginManager()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70
    {
71
        $defaultLoginManagerConfig = $this->loginManagerConfig[$this->config['defaultLoginManager']];
72
73
        $className = $defaultLoginManagerConfig['class'];
74
        $settings = $defaultLoginManagerConfig['settings'];
75
76
        return new $className($settings);
77
    }
78
}
79