CheckUser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 10
c 0
b 0
f 0
ccs 0
cts 9
cp 0
wmc 3
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
1
<?php
2
3
//For now, this is an example of how a plugin would work with more than one function to a class.
4
5
/**
6
 * This file is part of Peachy MediaWiki Bot API
7
 *
8
 * Peachy is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
class CheckUser {
23
24
	public function __construct(Wiki &$wikiclass = null)
0 ignored issues
show
Unused Code introduced by
The parameter $wikiclass is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25
	{
26
27
		$extensions = $wikiClass->get_extensions();
0 ignored issues
show
Bug introduced by
The variable $wikiClass does not exist. Did you mean $wikiclass?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
28
		if( !array_key_exists( 'CheckUser', $extensions ) ) {
29
			throw new DependencyError( "CheckUser", "http://www.mediawiki.org/wiki/Extension:CheckUser" );
0 ignored issues
show
Documentation introduced by
'http://www.mediawiki.or...ki/Extension:CheckUser' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
30
		} elseif( $extensions['CheckUser'] < 3 ) {
31
			throw new DependencyError( "CheckUser version 3.0 or up", "http://www.mediawiki.org/wiki/Extension:CheckUser" );
0 ignored issues
show
Documentation introduced by
'http://www.mediawiki.or...ki/Extension:CheckUser' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
32
		}
33
	}
34
}