File Utility.php
has 1363 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace XoopsModules\Wfdownloads;
/*
Function truncateHtml
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
{
if ($considerHtml) {
// if the plain text is shorter than the maximum length, return the whole text
if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
- 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
Utility
has 56 functions (exceeds 20 allowed). Consider refactoring. Open
class Utility extends Common\SysUtility
{
//--------------- Custom module methods -----------------------------
/**
* @param $categoryObj
Function displayIcons
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
public static function displayIcons($time, $status = \_WFDOWNLOADS_STATUS_WAITING, $counter = 0)
{
$helper = Helper::getInstance();
$new = '';
- 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
Function getDownloadTime
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
public static function getDownloadTime($size = 0, $gmodem = 1, $gisdn = 1, $gdsl = 1, $gslan = 0, $gflan = 0)
{
$aflag = [];
$amtime = [];
$artime = [];
- 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
Method editCategory
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCats = 4, $categoryObj = null)
{
$helper = Helper::getInstance();
// if there is a parameter, and the id exists, retrieve data: we're editing a category
Function createThumb
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static function createThumb($imgName, $imgPath, $imgSavePath, $width = 100, $height = 100, $quality = 100, $update = false, $aspect = 1)
{
$helper = Helper::getInstance();
// Paths
- 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
Function editCategory
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCats = 4, $categoryObj = null)
{
$helper = Helper::getInstance();
// if there is a parameter, and the id exists, retrieve data: we're editing a category
- 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
Function largeDownload
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public static function largeDownload($filePath, $fileMimetype)
{
/* You may need these ini settings too */
\set_time_limit(0);
\ini_set('memory_limit', '512M');
- 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
Method createThumb
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function createThumb($imgName, $imgPath, $imgSavePath, $width = 100, $height = 100, $quality = 100, $update = false, $aspect = 1)
{
$helper = Helper::getInstance();
// Paths
Function uploading
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public static function uploading(
$filename,
$uploadDirectory = 'uploads',
$allowedMimetypes = [],
$redirectURL = 'index.php',
- 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
Function copyDir
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public static function copyDir($source, $destination)
{
if (!$dirHandler = \opendir($source)) {
return false;
}
- 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
Method searchSwishe
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function searchSwishe($swisheQueryWords)
{
/**
* @param $str
* @param $num_chars
Method truncateHtml
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
{
if ($considerHtml) {
// if the plain text is shorter than the maximum length, return the whole text
if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
Method largeDownload
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function largeDownload($filePath, $fileMimetype)
{
/* You may need these ini settings too */
\set_time_limit(0);
\ini_set('memory_limit', '512M');
Function searchSwishe
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function searchSwishe($swisheQueryWords)
{
/**
* @param $str
* @param $num_chars
- 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
Method uploading
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function uploading(
$filename,
$uploadDirectory = 'uploads',
$allowedMimetypes = [],
$redirectURL = 'index.php',
Method getDownloadTime
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getDownloadTime($size = 0, $gmodem = 1, $gisdn = 1, $gdsl = 1, $gslan = 0, $gflan = 0)
{
$aflag = [];
$amtime = [];
$artime = [];
Function delDir
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function delDir($dir, $if_not_empty = true)
{
if (!\file_exists($dir)) {
return true;
}
- 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
Method convertHtml2text
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function convertHtml2text($document)
{
$search = [
"'<script[^>]*?>.*?</script>'si", // Strip out javascript
"'<img.*?>'si", // Strip out img tags
Method convertorderbyin
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function convertorderbyin($orderby)
{
switch (\trim($orderby)) {
case 'titleA':
$orderby = 'title ASC';
Method displayIcons
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function displayIcons($time, $status = \_WFDOWNLOADS_STATUS_WAITING, $counter = 0)
{
$helper = Helper::getInstance();
$new = '';
Function convertorderbyin
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function convertorderbyin($orderby)
{
switch (\trim($orderby)) {
case 'titleA':
$orderby = 'title ASC';
- 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
Method convertOrderByTrans
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function convertOrderByTrans($orderby)
{
$orderbyTrans = '';
if ('title ASC' === $orderby) {
$orderbyTrans = \_MD_WFDOWNLOADS_TITLEATOZ;
Method isNewImage
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function isNewImage($published)
{
if ($published <= 0) {
$indicator['image'] = 'assets/images/icon/download.gif';
$indicator['alttext'] = \_MD_WFDOWNLOADS_NO_FILES;
Method lettersChoice
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function lettersChoice()
{
$helper = Helper::getInstance();
$criteria = $helper->getHandler('Download')->getActiveCriteria();
Method convertorderbyout
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function convertorderbyout($orderby)
{
if ('title ASC' === $orderby) {
$orderby = 'titleA';
}
Function toolbar
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function toolbar()
{
$helper = Helper::getInstance();
$isSubmissionAllowed = false;
- 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
Function convertOrderByTrans
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function convertOrderByTrans($orderby)
{
$orderbyTrans = '';
if ('title ASC' === $orderby) {
$orderbyTrans = \_MD_WFDOWNLOADS_TITLEATOZ;
- 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
Function convertorderbyout
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function convertorderbyout($orderby)
{
if ('title ASC' === $orderby) {
$orderby = 'titleA';
}
- 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
Method displayCategory
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function displayCategory(Wfdownloads\Category $categoryObj, $level = 0)
{
$helper = Helper::getInstance();
$description = $categoryObj->description();
Method toolbar
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function toolbar()
{
$helper = Helper::getInstance();
$isSubmissionAllowed = false;
Method createThumb
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function createThumb($imgName, $imgPath, $imgSavePath, $width = 100, $height = 100, $quality = 100, $update = false, $aspect = 1)
Method uploading
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
$filename,
$uploadDirectory = 'uploads',
$allowedMimetypes = [],
$redirectURL = 'index.php',
$num = 0,
Method getDownloadTime
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function getDownloadTime($size = 0, $gmodem = 1, $gisdn = 1, $gdsl = 1, $gslan = 0, $gflan = 0)
Function download
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function download($filePath, $isBinary = true, $retBytes = true)
{
// how many bytes per chunk
//$chunkSize = 1 * (1024 * 1024);
$chunkSize = 8 * (1024 * 1024); //8MB (highest possible fread length)
- 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
Function displayImage
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function displayImage($image = '', $href = '', $imgSource = '', $altText = '')
{
$helper = Helper::getInstance();
$showImage = '';
- 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
Method truncateHtml
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
Function getFiles
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function getFiles($path = '.')
{
$files = [];
$dir = \opendir($path);
while (false !== ($file = \readdir($dir))) {
- 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
Function getDir
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function getDir($path = '.', $level = 0)
{
$ret = [];
$ignore = ['cgi-bin', '.', '..'];
// Directories to ignore when listing output. Many hosts will deny PHP access to the cgi-bin.
- 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
Function displayCategory
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function displayCategory(Wfdownloads\Category $categoryObj, $level = 0)
{
$helper = Helper::getInstance();
$description = $categoryObj->description();
- 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
Function makeDir
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function makeDir($dir, $perm = 0777, $create_index = true)
{
if (!\mkdir($dir, $perm) && !\is_dir($dir)) {
throw new \RuntimeException('The directory ' . $dir . ' could not be created.');
}
- 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
Function isNewImage
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function isNewImage($published)
{
if ($published <= 0) {
$indicator['image'] = 'assets/images/icon/download.gif';
$indicator['alttext'] = \_MD_WFDOWNLOADS_NO_FILES;
- 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
Function sortCategories
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function sortCategories($pid = 0, $level = 0)
{
$helper = Helper::getInstance();
$sorted = [];
- 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
Function sizeToBytes1024
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function sizeToBytes1024($size)
{
$l = mb_substr($size, -1);
$ret = mb_substr($size, 0, -1);
switch (mb_strtoupper($l)) {
- 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
Function lettersChoice
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function lettersChoice()
{
$helper = Helper::getInstance();
$criteria = $helper->getHandler('Download')->getActiveCriteria();
- 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
Function generateSeoUrl
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function generateSeoUrl($op, $id, $title = '')
{
if (\defined('SEO_ENABLED')) {
if (SEO_ENABLED === 'rewrite') {
// generate SEO url using htaccess
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($considerHtml) {
// if the plain text is shorter than the maximum length, return the whole text
if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
return $text;
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 521.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
public static function cloneRecord($tableName, $id_field, $id)
{
$new_id = false;
$table = $GLOBALS['xoopsDB']->prefix($tableName);
// copy content of the record you wish to clone
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 203.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76