Passed
Push — master ( bc9a55...f3faba )
by Dark❶
07:56
created

ext   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 1
b 0
f 0
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pbpbb_ver_chk() 0 9 3
A is_enableable() 0 3 1
1
<?php
2
/**
3
 *
4
 * User Notification Control [UNC]. An extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2020, Dark❶, https://dark1.tech
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace dark1\usernotificationcontrol;
12
13
/**
14
 * @ignore
15
 */
16
use phpbb\extension\base;
17
18
/**
19
 * User Notification Control [UNC] Extension base
20
 *
21
 * It is recommended to remove this file from
22
 * an extension if it is not going to be used.
23
 */
24
class ext extends base
25
{
26
	/** string Require phpBB v3.2.10 due to events. */
27
	const PHPBB_MIN_3_2_X = '3.2.10';
28
29
	/** string Require phpBB v3.3.1 due to events. */
30
	const PHPBB_MIN_3_3_X = '3.3.1';
31
32
	/**
33
	 * {@inheritdoc}
34
	 */
35
	public function is_enableable()
36
	{
37
		return $this->pbpbb_ver_chk();
38
	}
39
40
	/**
41
	 * phpBB Version Check.
42
	 *
43
	 * @return bool
44
	 * @access private
45
	 */
46
	private function pbpbb_ver_chk()
47
	{
48
		$config = $this->container->get('config');
49
50
		$phpbb_version = phpbb_version_compare(PHPBB_VERSION, $config['version'], '>=') ? PHPBB_VERSION : $config['version'] ;
51
		list($v1, $v2) = explode('.', $phpbb_version);
52
		$phpbb_min_version = 'self::PHPBB_MIN_' . $v1 . '_' . $v2 . '_X';
53
54
		return defined($phpbb_min_version) ? phpbb_version_compare($phpbb_version, constant($phpbb_min_version), '>=') : false ;
55
	}
56
}
57