Completed
Pull Request — master (#23)
by
unknown
02:00
created

ext::enable_step()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 30
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 30
rs 8.5806
c 1
b 0
f 0
cc 4
eloc 15
nc 4
nop 1
1
<?php
2
/**
3
 *
4
 * Precise Similar Topics
5
 *
6
 * @copyright (c) 2014 Matt Friedman
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace vse\similartopics;
12
13
class ext extends \phpbb\extension\base
14
{
15
16
	public function is_enableable()
17
	{
18
		global $db;
19
		$fulltext = new \vse\similartopics\core\fulltext_support($db);
20
		if (!$fulltext->is_mysql() & !$fulltext->is_postgres())
21
		{
22
			$this->container->get('user')->add_lang_ext('vse/similartopics', 'info_acp_similar_topics');
23
			trigger_error($this->container->get('user')->lang['PST_NOT_COMPATIBLE'], E_USER_WARNING);
24
			return false;
25
		}
26
27
		return true;
28
	}
29
30
	function enable_step($old_state)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
31
	{
32
		switch ($old_state)
33
		{
34
			case '': // Empty means nothing has run yet
35
				if (empty($old_state))
36
				{
37
					global $db;
38
					$fulltext = new \vse\similartopics\core\fulltext_support($db);
39
					if ($fulltext->is_postgres())
40
					{
41
						$this->container->get('user')->add_lang_ext('vse/similartopics', 'info_acp_similar_topics');
42
						$this->container->get('template')->assign_var('L_EXTENSION_ENABLE_SUCCESS', $this->container->get('user')->lang['EXTENSION_ENABLE_SUCCESS'] .
43
								$this->container->get('user')->lang['PST_LOG_CREATE_INDEX'] );
44
					}
45
				}
46
47
				// Run parent enable step method
48
				return parent::enable_step($old_state);
49
50
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
51
52
			default:
0 ignored issues
show
Coding Style introduced by
The default body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a default statement must start on the line immediately following the statement.

switch ($expr) {
    default:
        doSomething(); //right
        break;
}


switch ($expr) {
    default:

        doSomething(); //wrong
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
53
54
				// Run parent enable step method
55
				return parent::enable_step($old_state);
56
57
				break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
58
		}
59
	}
60
}
61