AdminerKfr   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 68.18 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 15
loc 22
rs 10
wmc 4
lcom 0
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 4 4 1
A credentials() 4 4 1
A database() 3 4 1
A login() 0 4 1

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
 * Adminer Module based on Ghost Module
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright           The XOOPS Project http://sourceforge.net/projects/xoops/
13
 * @license             http://www.fsf.org/copyleft/gpl.html GNU public license
14
 * @package             Adminer Module
15
 * @since               2.3.0
16
 * @author              Kris <http://www.xoofoo.org>
17
 * @version             $Id $
18
 **/
19
20
// connect xoops database
21
defined('XOOPS_ROOT_PATH') || include dirname(dirname(__DIR__)) . '/mainfile.php';
22
23
$moduleDirName = basename(__DIR__);
24
include(XOOPS_ROOT_PATH . '/header.php');
25
26 View Code Duplication
if (!is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
27
    exit(_NOPERM);
28
}
29 View Code Duplication
function adminer_object()
0 ignored issues
show
Duplication introduced by
This function 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...
Best Practice introduced by
The function adminer_object() has been defined more than once; this definition is ignored, only the first definition in admin/getEditor.php (L26-74) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
30
{
31
    class AdminerKfr extends Adminer
32
    {
33
        public function name()
34
        {
35
            return 'XOOPS Admin';
36
        }
37
38
        public function credentials()
39
        {
40
            return array(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS);
41
        }
42
43
        public function database()
44
        {
45
            return XOOPS_DB_NAME;
46
        }
47
48
        public function login($login, $password)
49
        {
50
            return ($login == XOOPS_DB_USER);
51
        }
52
    }
53
54
    return new AdminerKfr;
55
}
56
57
include __DIR__ . '/include/editor.php';
58