Completed
Push — master ( 54dd0f...5e6629 )
by Park Jong-Hun
03:04
created

AuthManager   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 45 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 1
cbo 0
dl 18
loc 40
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setConfig() 0 4 1
A isDefaultAllow() 0 4 1
A getAccountManager() 9 9 2
A getLoginManager() 9 9 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace App\Auth;
4
5
class AuthManager
6
{
7
    private static $config = [];
8
9
    public static function setConfig(array $config)
10
    {
11
        self::$config = $config;
12
    }
13
14
    public static function isDefaultAllow()
15
    {
16
        return self::$config['defaultAllow'];
17
    }
18
19
    /**
20
     * @return AccountManagerInterface
21
     */
22 View Code Duplication
    public static function getAccountManager($accountManagerName = null)
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...
23
    {
24
        $accountManagerName = $accountManagerName ?: self::$config['defaultAccountManager'];
25
26
        $className = self::$config['accountManagers'][$accountManagerName]['class'];
27
        $settings = self::$config['accountManagers'][$accountManagerName]['settings'];
28
29
        return new $className($settings);
30
    }
31
32
    /**
33
     * @return LoginManagerInterface
34
     */
35 View Code Duplication
    public static function getLoginManager($loginManagerName = null)
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...
36
    {
37
        $loginManagerName = $loginManagerName ?: self::$config['defaultLoginManager'];
38
39
        $className = self::$config['loginManagers'][$loginManagerName]['class'];
40
        $settings = self::$config['loginManagers'][$loginManagerName]['settings'];
41
42
        return new $className($settings);
43
    }
44
}
45