Passed
Push — 0.4.0 ( cba0fe...bc0e2e )
by Anton
03:10
created

Informer   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 32
Duplicated Lines 34.38 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 2
dl 11
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A countEntries() 11 11 4
A checkInstallFile() 0 4 1
A mysqlVersion() 0 6 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Modules {
4
5
	use DB, Explorer;
6
7
	abstract class Informer {
8
9
		# Count table entries
10
11 View Code Duplication
		public static function countEntries(string $table, bool $false_on_error = false) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
13
			if (!(DB::select($table, 'COUNT(id) as count') && (DB::getLast()->rows === 1))) {
14
15
				return (!$false_on_error ? 0 : false);
16
			}
17
18
			# ------------------------
19
20
			return intval(DB::getLast()->getRow()['count']);
21
		}
22
23
		# Check if install file exists
24
25
		public static function checkInstallFile() {
26
27
			return Explorer::isFile(DIR_WWW . 'install.php');
28
		}
29
30
		# Get MySQL version
31
32
		public static function mysqlVersion() {
33
34
			if (!(DB::send("SELECT VERSION() as version") && DB::getLast()->status)) return false;
35
36
			return strval(DB::getLast()->getRow()['version']);
37
		}
38
	}
39
}
40