Completed
Push — master ( 61be05...2cc598 )
by Matt
06:48 queued 04:17
created

ext   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A is_enableable() 0 17 2
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