ext   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 8
Bugs 0 Features 0
Metric Value
wmc 4
eloc 21
c 8
b 0
f 0
dl 0
loc 51
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A status_name() 0 3 1
A is_enableable() 0 5 3
1
<?php
2
/**
3
 *
4
 * Ideas extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\ideas;
12
13
/**
14
* This ext class is optional and can be omitted if left empty.
15
* However, you can add special (un)installation commands in the
16
* methods enable_step(), disable_step() and purge_step(). As it is,
17
* these methods are defined in \phpbb\extension\base, which this
18
* class extends, but you can overwrite them to give special
19
* instructions for those cases.
20
*/
21
class ext extends \phpbb\extension\base
22
{
23
	public const SORT_AUTHOR = 'author';
24
	public const SORT_DATE = 'date';
25
	public const SORT_NEW = 'new';
26
	public const SORT_SCORE = 'score';
27
	public const SORT_TITLE = 'title';
28
	public const SORT_TOP = 'top';
29
	public const SORT_VOTES = 'votes';
30
	public const SORT_MYIDEAS = 'egosearch';
31
	public const SUBJECT_LENGTH = 120;
32
	public const NUM_IDEAS = 5;
33
34
	/** @var array Idea status names and IDs */
35
	public static $statuses = array(
36
		'NEW'			=> 1,
37
		'IN_PROGRESS'	=> 2,
38
		'IMPLEMENTED'	=> 3,
39
		'DUPLICATE'		=> 4,
40
		'INVALID'		=> 5,
41
	);
42
43
	/**
44
	 * Return the status name from the status ID.
45
	 *
46
	 * @param int $id ID of the status.
47
	 *
48
	 * @return string The status name.
49
	 * @static
50
	 * @access public
51
	 */
52
	public static function status_name($id)
53
	{
54
		return array_flip(self::$statuses)[$id];
55
	}
56
57
	/**
58
	 * Check whether the extension can be enabled.
59
	 *
60
	 * Requires phpBB >= 3.2.3 due to removal of deprecated Twig functions (ie Twig_SimpleFunction)
61
	 * Requires phpBB >= 3.3.0 due to use of PHP 7 features
62
	 * Requires PHP >= 7.1.0
63
	 *
64
	 * @return bool
65
	 * @access public
66
	 */
67
	public function is_enableable()
68
	{
69
		return !(PHP_VERSION_ID < 70100 ||
70
			phpbb_version_compare(PHPBB_VERSION, '3.3.0', '<') ||
71
			phpbb_version_compare(PHPBB_VERSION, '4.0.0-dev', '>='));
72
	}
73
}
74