File UploadHandler.php
has 647 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace XoopsModules\Smallworld;
/*
UploadHandler
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
class UploadHandler
{
protected $options;
// PHP File Upload error message codes:
Function handle_file_upload
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
protected function handle_file_upload(
$uploaded_file,
$name,
$size,
$type,
- 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 validate
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected function validate($uploaded_file, $file, $error, $index)
{
if ($error) {
$file->error = $this->get_error_message($error);
- 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 create_scaled_image
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function create_scaled_image($file_name, $version, $options)
{
$file_path = $this->get_upload_path($file_name);
if (!empty($version)) {
$version_dir = $this->get_upload_path(null, $version);
- 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 create_scaled_image
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function create_scaled_image($file_name, $version, $options)
{
$file_path = $this->get_upload_path($file_name);
if (!empty($version)) {
$version_dir = $this->get_upload_path(null, $version);
Method __construct
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($options = null, $initialize = true)
{
$userID = $GLOBALS['xoopsUser']->getVar('uid');
$this->options = [
'script_url' => $this->get_full_url() . '/imgupload.php',
Method handle_file_upload
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function handle_file_upload(
$uploaded_file,
$name,
$size,
$type,
Method validate
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function validate($uploaded_file, $file, $error, $index)
{
if ($error) {
$file->error = $this->get_error_message($error);
Function delete
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function delete($print_response = true)
{
$userid = $GLOBALS['xoopsUser']->getVar('uid');
$swDB = new SwDatabase();
$file_name = $this->get_file_name_param();
- 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 orient_image
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function orient_image($file_path)
{
if (!function_exists('exif_read_data')) {
return false;
}
Function get_file_object
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function get_file_object($file_name)
{
if ($this->is_valid_file_object($file_name)) {
$file = new \stdClass();
$file->name = $file_name;
- 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 generate_response
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function generate_response($content, $print_response = true)
{
if ($print_response) {
$json = json_encode($content);
$redirect = isset($_REQUEST['redirect']) ? stripslashes($_REQUEST['redirect']) : 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 handle_file_upload
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
$uploaded_file,
$name,
$size,
$type,
$error,
Function download
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function download()
{
if (!$this->options['download_via_php']) {
$this->header('HTTP/1.1 403 Forbidden');
- 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 orient_image
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function orient_image($file_path)
{
if (!function_exists('exif_read_data')) {
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
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return $success;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Function post
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function post($print_response = true)
{
if (isset($_REQUEST['_method']) && 'DELETE' === $_REQUEST['_method']) {
return $this->delete($print_response);
}
- 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"