CustomAuthExamplePlugin   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Init() 0 4 1
A FilterLoginСredentials() 0 20 2
1
<?php
2
3
class CustomAuthExamplePlugin extends \RainLoop\Plugins\AbstractPlugin
4
{
5
	public function Init()
6
	{
7
		$this->addHook('filter.login-credentials', 'FilterLoginСredentials');
8
	}
9
10
	/**
11
	 * @param string $sEmail
12
	 * @param string $sLogin
13
	 * @param string $sPassword
14
	 *
15
	 * @throws \RainLoop\Exceptions\ClientException
16
	 */
17
	public function FilterLoginСredentials(&$sEmail, &$sLogin, &$sPassword)
18
	{
19
		// Your custom php logic
20
		// You may change login credentials
21
		if ('[email protected]' === $sEmail)
22
		{
23
			$sEmail = '[email protected]';
24
			$sLogin = '[email protected]';
25
			$sPassword = 'super-puper-password';
26
		}
27
		else
28
		{
29
			// or throw auth exeption
30
			throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError);
31
			// or
32
			throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AccountNotAllowed);
0 ignored issues
show
Unused Code introduced by
throw new \RainLoop\Exce...ns::AccountNotAllowed); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
33
			// or
34
			throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DomainNotAllowed);
0 ignored issues
show
Unused Code introduced by
throw new \RainLoop\Exce...ons::DomainNotAllowed); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
35
		}
36
	}
37
}
38