RedirectFormFinder::redirectToUrl()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
ccs 7
cts 7
cp 1
crap 2
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