File class.general.php
has 791 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @package toolkit
*/
/**
General
has 53 functions (exceeds 20 allowed). Consider refactoring. Open
class General
{
/**
* Convert any special characters into their entity equivalents. Since
* Symphony 2.3, this function assumes UTF-8 and will not double
Function listStructure
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public static function listStructure($dir = ".", $filters = array(), $recurse = true, $sort = "asc", $strip_root = null, $exclude = array(), $ignore_hidden = true)
{
if (!is_dir($dir)) {
return null;
}
- 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 processFilePostData
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public static function processFilePostData($filedata)
{
$result = array();
foreach ($filedata as $key => $data) {
- 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 array_to_xml
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public static function array_to_xml(XMLElement $parent, array $data, $validate = false)
{
foreach ($data as $element_name => $value) {
if (!is_numeric($value) && empty($value)) {
continue;
- 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 listDirStructure
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static function listDirStructure($dir = '.', $filter = null, $recurse = true, $strip_root = null, $exclude = array(), $ignore_hidden = true)
{
if (!is_dir($dir)) {
return null;
}
- 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 listStructure
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function listStructure($dir = ".", $filters = array(), $recurse = true, $sort = "asc", $strip_root = null, $exclude = array(), $ignore_hidden = true)
{
if (!is_dir($dir)) {
return null;
}
Method getMimeType
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getMimeType($file)
{
if (!empty($file)) {
// in PHP 5.3 we can use 'finfo'
if (PHP_VERSION_ID >= 50300 && function_exists('finfo_open')) {
Function ensureType
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function ensureType(array $params)
{
foreach ($params as $name => $param) {
if (isset($param['optional']) && ($param['optional'] === true)) {
if (empty($param['var'])) {
- 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 validateString
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function validateString($string, $rule)
{
if (!is_array($rule) && ($rule == '' || $rule == null)) {
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
Function in_array_multi
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static function in_array_multi($needle, $haystack)
{
if ($needle == $haystack) {
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
Function deleteDirectory
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function deleteDirectory($dir, $silent = true)
{
try {
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
Function getPostData
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function getPostData()
{
$files = array(
'name' => array(),
'type' => array(),
- 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 createHandle
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function createHandle($string, $max_length = 255, $delim = '-', $uriencode = false, $additional_rule_set = null)
{
// If empty, bail out quick
if (empty(trim($string))) {
return '';
Method validateXML
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function validateXML($data, &$errors, $isFile = true, $xsltProcessor = null, $encoding = 'UTF-8')
{
$_data = ($isFile) ? file_get_contents($data) : $data;
$_data = preg_replace('/<!DOCTYPE[-.:"\'\/\\w\\s]+>/', null, $_data);
Consider simplifying this complex logical expression. Open
if (
($file == '.' || $file == '..')
|| ($ignore_hidden && $file{0} == '.')
|| !is_dir("$dir/$file")
|| in_array($file, $exclude)
Function flattenArray
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function flattenArray(array &$source, &$output = null, $path = null)
{
if (is_null($output)) {
$output = array();
}
- 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 getMimeType
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function getMimeType($file)
{
if (!empty($file)) {
// in PHP 5.3 we can use 'finfo'
if (PHP_VERSION_ID >= 50300 && function_exists('finfo_open')) {
- 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 createHandle
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function createHandle($string, $max_length = 255, $delim = '-', $uriencode = false, $additional_rule_set = null)
{
// If empty, bail out quick
if (empty(trim($string))) {
return '';
- 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 listStructure
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function listStructure($dir = ".", $filters = array(), $recurse = true, $sort = "asc", $strip_root = null, $exclude = array(), $ignore_hidden = true)
Method listDirStructure
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function listDirStructure($dir = '.', $filter = null, $recurse = true, $strip_root = null, $exclude = array(), $ignore_hidden = true)
Function uploadFile
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function uploadFile($dest_path, $dest_name, $tmp_name, $perm = 0644)
{
// Upload the file
if (@is_uploaded_file($tmp_name)) {
$dest_path = rtrim($dest_path, '/') . '/';
- 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
Consider simplifying this complex logical expression. Open
if (
($file == '.' || $file === '..')
|| ($ignore_hidden && $file{0} === '.')
|| in_array($file, $exclude)
|| in_array("$dir/$file", $exclude)
Method createHandle
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function createHandle($string, $max_length = 255, $delim = '-', $uriencode = false, $additional_rule_set = null)
Method validateXML
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function validateXML($data, &$errors, $isFile = true, $xsltProcessor = null, $encoding = 'UTF-8')
Method createXMLDateObject
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function createXMLDateObject($timestamp, $element = 'date', $date_format = 'Y-m-d', $time_format = 'H:i', $namespace = null)
Method writeFile
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function writeFile($file, $data, $perm = 0644, $mode = 'w', $trim = false)
Function validateXML
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function validateXML($data, &$errors, $isFile = true, $xsltProcessor = null, $encoding = 'UTF-8')
{
$_data = ($isFile) ? file_get_contents($data) : $data;
$_data = preg_replace('/<!DOCTYPE[-.:"\'\/\\w\\s]+>/', null, $_data);
- 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 too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Function writeFile
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function writeFile($file, $data, $perm = 0644, $mode = 'w', $trim = false)
{
if (static::checkFileWritable($file) === false) {
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
Function limitWords
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function limitWords($string, $maxChars = 200, $appendHellip = false)
{
if ($appendHellip) {
$maxChars -= 1;
}
- 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 mergeFilePostData
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected static function mergeFilePostData($type, array $file, array &$post)
{
foreach ($file as $key => $value) {
if (!isset($post[$key])) {
$post[$key] = array();
- 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"