RedirectFormFinder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
3
namespace SES;
4
5
use OutputPage;
6
use SpecialPage;
7
8
/**
9
 * @license GNU GPL v3+
10
 * @since 1.0
11
 *
12
 * @author mwjames
13
 */
14
class RedirectFormFinder {
15
16
	/**
17
	 * @var FormPrinterHandler
18
	 */
19
	private $formPrinterHandler;
20
21
	/**
22
	 * @since 1.1
23
	 *
24
	 * @param FormPrinterHandler $formPrinterHandler
25
	 */
26 3
	public function __construct( FormPrinterHandler $formPrinterHandler ) {
27 3
		$this->formPrinterHandler = $formPrinterHandler;
28 3
	}
29
30
	/**
31
	 * @since 1.0
32
	 *
33
	 * @param OutputPage $output
34
	 *
35
	 * @return boolean
36
	 */
37 2
	public function redirectToUrl( $output ) {
38
39 2
		if ( !$this->formPrinterHandler->canUseForm() ) {
40 1
			return true;
41
		}
42
43 1
		$url = htmlspecialchars( SpecialPage::getTitleFor( 'SemanticSignup' )->getFullURL() );
44
45 1
		wfRunHooks( 'SemanticSignupBeforeRedirect', array( &$url ) );
46
47 1
		$output->redirect( $url );
48
49 1
		return false;
50
	}
51
}
52