admin/watermark-border.php
File watermark-border.php
has 432 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
/**
* ExtGallery Admin settings
* Manage admin pages
Avoid deeply nested control flow statements. Open
Open
if (preg_match('/.*ttf/', mb_strtolower($f))) {
$fonts[] = $f;
}
Avoid deeply nested control flow statements. Open
Open
if ($helper->getConfig('watermark_text') != $_POST['watermark_text']) {
$criteria = new \CriteriaCompo();
$criteria->add($moduleIdCriteria);
$criteria->add(new \Criteria('conf_name', 'watermark_text'));
$config = $configHandler->getConfigs($criteria);
Function getImageTest
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
function getImageTest()
{
$ret = [];
$rep = \dirname(__DIR__) . '/assets/images/';
$dir = opendir($rep);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid variables with short names like $f. Configured minimum length is 3. Open
Open
while (false !== ($f = readdir($dir))) {
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 340 and the first side effect is on line 22. Open
Open
<?php
- Exclude checks
The CASE body must start on the line following the statement Open
Open
case 'default':
- Exclude checks
The DEFAULT body must start on the line following the statement Open
Open
default:
- Exclude checks
The CASE body must start on the line following the statement Open
Open
case 'default':
- Exclude checks
The CASE body must start on the line following the statement Open
Open
case 'conf':
- Exclude checks
The CASE body must start on the line following the statement Open
Open
case 'uploadfont':
- Exclude checks
The DEFAULT body must start on the line following the statement Open
Open
default:
- Exclude checks
The CASE body must start on the line following the statement Open
Open
case 'enreg':
- Exclude checks
The CASE body must start on the line following the statement Open
Open
case 'enreg':
- Exclude checks
Line exceeds 120 characters; contains 159 characters Open
Open
$form->addElement(new \XoopsFormText(_AM_EXTGALLERY_OUTER_BORDER_SIZE, 'outer_border_size', '2', '2', $helper->getConfig('outer_border_size')), false);
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
Open
$fontSelect = new \XoopsFormSelect(_AM_EXTGALLERY_FONT, 'watermark_font', $helper->getConfig('watermark_font'));
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
Open
$imageTransform->save('../assets/images/watermark-border-test-' . mb_substr(md5(uniqid(mt_rand(), true)), 27) . '.jpg');
- Exclude checks
Line exceeds 120 characters; contains 159 characters Open
Open
$form->addElement(new \XoopsFormText(_AM_EXTGALLERY_INNER_BORDER_SIZE, 'inner_border_size', '2', '2', $helper->getConfig('inner_border_size')), false);
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
Open
$positionSelect = new \XoopsFormSelect(_AM_EXTGALLERY_POSITION, 'watermark_position', $helper->getConfig('watermark_position'));
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
Open
$form->addElement(new \XoopsFormFile(_AM_EXTGALLERY_FONT_FILE, 'font_file', get_cfg_var('upload_max_filesize') * 1024 * 1024), false);
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
Open
$form = new \XoopsThemeForm(_AM_EXTGALLERY_WATERMARK_CONF, 'watermark_conf', 'watermark-border.php?op=conf', 'post', true);
- Exclude checks
Line exceeds 120 characters; contains 163 characters Open
Open
$form->addElement(new \XoopsFormText(_AM_EXTGALLERY_WATERMARK_PADDING, 'watermark_padding', '2', '2', $helper->getConfig('watermark_padding')), false);
- Exclude checks
Line exceeds 120 characters; contains 181 characters Open
Open
$onClick = ' onClick="document.getElementById(\'watermark_text\').disabled = false; document.getElementById(\'watermark_text\').style.backgroundColor = \'#FFFFFF\';"';
- Exclude checks
Line exceeds 120 characters; contains 154 characters Open
Open
$form->addElement(new \XoopsFormColorPicker(_AM_EXTGALLERY_WATERMARK_COLOR, 'watermark_color', $helper->getConfig('watermark_color')), false);
- Exclude checks
Line exceeds 120 characters; contains 159 characters Open
Open
$form->addElement(new \XoopsFormColorPicker(_AM_EXTGALLERY_INNER_BORDER_COLOR, 'inner_border_color', $helper->getConfig('inner_border_color')), false);
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
Open
$text = (0 == $testParam['watermark_type']) ? $GLOBALS['xoopsUser']->getVar('uname') : $testParam['watermark_text'];
- Exclude checks
Line exceeds 120 characters; contains 180 characters Open
Open
$onClick = ' onClick="document.getElementById(\'watermark_text\').disabled = true; document.getElementById(\'watermark_text\').style.backgroundColor = \'#DDDDDD\';"';
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
Open
$xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/extgallery/templates/admin/extgallery_admin_watermark_border.tpl');
- Exclude checks
Line exceeds 120 characters; contains 279 characters Open
Open
$WTextForm = '<input type="radio" name="watermark_type" value="1"' . $selected1 . $onClick . '> <input name="watermark_text" id="watermark_text" size="50" maxlength="255" value="' . $helper->getConfig('watermark_text') . '" type="text"' . $disable . $style . '><br>';
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
Open
$WTextForm .= '<input type="radio" name="watermark_type" value="0"' . $selected2 . $onClick . '> ' . _AM_EXTGALLERY_PRINT_SUBMITTER_UNAME;
- Exclude checks
Line exceeds 120 characters; contains 167 characters Open
Open
$form->addElement(new \XoopsFormText(_AM_EXTGALLERY_WATERMARK_FONT_SIZE, 'watermark_fontsize', '2', '2', $helper->getConfig('watermark_fontsize')), false);
- Exclude checks
Line exceeds 120 characters; contains 159 characters Open
Open
$form->addElement(new \XoopsFormColorPicker(_AM_EXTGALLERY_OUTER_BORDER_COLOR, 'outer_border_color', $helper->getConfig('outer_border_color')), false);
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
Open
$form = new \XoopsThemeForm(_AM_EXTGALLERY_ADD_FONT, 'add_font', 'watermark-border.php?op=uploadfont', 'post', true);
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
Open
$form = new \XoopsThemeForm(_AM_EXTGALLERY_BORDER_CONF, 'border_conf', 'watermark-border.php?op=conf', 'post', true);
- Exclude checks