CustomAuthExamplePlugin::Init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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