Completed
Push — master ( 2cc598...1ffcb6 )
by Matt
07:06 queued 05:10
created

ext::is_enableable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
1
<?php
2
/**
3
 *
4
 * Topic Image Preview. An extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2017, Matt Friedman
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace vse\TopicImagePreview;
12
13
class ext extends \phpbb\extension\base
14
{
15
	/**
16
	 * {@inheritdoc}
17
	 */
18
	public function is_enableable()
19
	{
20
		// Requires phpBB 3.2.0 or newer.
21
		$is_enableable = phpbb_version_compare(PHPBB_VERSION, '3.2.0', '>=');
22
23
		// Display a custom warning message if requirement fails.
24
		if (!$is_enableable)
25
		{
26
			$lang = $this->container->get('language');
27
			$lang->add_lang('tip_acp', 'vse/TopicImagePreview');
28
29
			// Suppress the error in case of CLI usage
30
			@trigger_error($lang->lang('ACP_TIP_INSTALL_ERROR'), E_USER_WARNING);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
31
		}
32
33
		return $is_enableable;
34
	}
35
}
36