Completed
Branch master (f6055e)
by Michael
02:50
created

ModuleConfigurator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 40 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 29 and the first side effect is on line 22.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
/**
12
 * animal module for xoops
13
 *
14
 * @copyright       XOOPS Project (http://xoops.org)
15
 * @license         GPL 2.0 or later
16
 * @package         Publisher
17
 * @subpackage      Config
18
 * @since           1.03
19
 * @author          XOOPS Development Team - ( http://xoops.org )
20
 */
21
22
require_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php';
23
24
$moduleDirName = basename(dirname(__DIR__));
25
26
$capsDirName = strtoupper($moduleDirName);
27
28
if (!defined($capsDirName . '_DIRNAME')) {
29
    define($capsDirName . '_DIRNAME', $moduleDirName);
30
    define($capsDirName . '_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($capsDirName . '_DIRNAME'));
31
    define($capsDirName . '_URL', XOOPS_URL . '/modules/' . constant($capsDirName . '_DIRNAME'));
32
    define($capsDirName . '_ADMIN', constant($capsDirName . '_URL') . '/admin/index.php');
33
    define($capsDirName . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($capsDirName . '_DIRNAME'));
34
    define($capsDirName . '_AUTHOR_LOGOIMG', constant($capsDirName . '_URL') . '/assets/images/logoModule.png');
35
}
36
37
// Define here the place where main upload path
38
39
//$img_dir = $GLOBALS['xoopsModuleConfig']['uploaddir'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
40
41
//define($capsDirName . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . constant($capsDirName . '_DIRNAME')); // WITHOUT Trailing slash
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
42
defined($capsDirName . '_UPLOAD_PATH') or define($capsDirName . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . constant($capsDirName . '_DIRNAME')); // WITHOUT Trailing slash
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as or instead of || is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
43
44
//Configurator
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
45
/*
46
return array(
47
    'name'           => 'Module Configurator',
48
    'uploadFolders'  => array(
49
        constant($capsDirName . '_UPLOAD_PATH'),
50
        constant($capsDirName . '_UPLOAD_PATH') . '/content',
51
        constant($capsDirName . '_UPLOAD_PATH') . '/images',
52
        constant($capsDirName . '_UPLOAD_PATH') . '/images/category',
53
        constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails',
54
    ),
55
    'blankFiles' => array(
56
        constant($capsDirName . '_UPLOAD_PATH'),
57
        constant($capsDirName . '_UPLOAD_PATH') . '/images/category',
58
        constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails',
59
    ),
60
61
    'templateFolders' => array(
62
        '/templates/',
63
        '/templates/blocks/',
64
        '/templates/admin/'
65
66
    ),
67
    'oldFiles'        => array(
68
        '/class/request.php',
69
        '/class/registry.php',
70
        '/class/utilities.php',
71
        '/class/util.php',
72
        '/include/constants.php',
73
        '/include/functions.php',
74
        '/ajaxrating.txt'
75
    ),
76
    'oldFolders'      => array(
77
        '/images',
78
        '/css',
79
        '/js',
80
        '/tcpdf',
81
    ),
82
);
83
*/
84
85
/**
86
 * Class ModuleConfigurator
87
 */
88
class ModuleConfigurator
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
89
{
90
    public $uploadFolders   = [];
91
    public $blankFiles  = [];
92
    public $templateFolders = [];
93
    public $oldFiles        = [];
94
    public $oldFolders      = [];
95
    public $name;
96
97
    /**
98
     * ModuleConfigurator constructor.
99
     */
100
    public function __construct()
101
    {
102
        $moduleDirName        = basename(dirname(__DIR__));
103
        $capsDirName          = strtoupper($moduleDirName);
104
        $this->name           = 'Module Configurator';
105
        $this->uploadFolders  = [
106
            constant($capsDirName . '_UPLOAD_PATH'),
107
            constant($capsDirName . '_UPLOAD_PATH') . '/content',
108
            constant($capsDirName . '_UPLOAD_PATH') . '/images',
109
            constant($capsDirName . '_UPLOAD_PATH') . '/images/category',
110
            constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails',
111
        ];
112
        $this->blankFiles = [
113
            constant($capsDirName . '_UPLOAD_PATH'),
114
            constant($capsDirName . '_UPLOAD_PATH') . '/images/category',
115
            constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails',
116
        ];
117
118
        $this->templateFolders = [
119
            '/templates/',
120
            '/templates/blocks/',
121
            '/templates/admin/'
122
123
        ];
124
        $this->oldFiles        = [
125
            '/class/request.php',
126
            '/class/registry.php',
127
            '/class/utilities.php',
128
            '/class/util.php',
129
            '/include/constants.php',
130
            '/include/functions.php',
131
            '/ajaxrating.txt'
132
        ];
133
        $this->oldFolders      = [
134
            '/images',
135
            '/css',
136
            '/js',
137
            '/tcpdf',
138
        ];
139
    }
140
}
141