MediaHandler
has 62 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class MediaHandler {
public const TRANSFORM_LATER = 1;
public const METADATA_GOOD = true;
public const METADATA_BAD = false;
public const METADATA_COMPATIBLE = 2; // for old but backwards compatible.
File MediaHandler.php
has 358 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
Function getSizeAndMetadataWithFallback
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
final public function getSizeAndMetadataWithFallback( $file, $path ) {
if ( !$this->useLegacyMetadata() ) {
if ( $file instanceof MediaHandlerState ) {
$state = $file;
} else {
- 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 getSizeAndMetadataWithFallback
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
final public function getSizeAndMetadataWithFallback( $file, $path ) {
if ( !$this->useLegacyMetadata() ) {
if ( $file instanceof MediaHandlerState ) {
$state = $file;
} else {
Function getPageRangesByDimensions
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function getPageRangesByDimensions( $pagesByDimensions ) {
$pageRangesByDimensions = [];
foreach ( $pagesByDimensions as $dimensions => $pageList ) {
$ranges = [];
- 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 formatMetadataHelper
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function formatMetadataHelper( $metadataArray, $context = false ) {
$result = [
'visible' => [],
'collapsed' => []
];
- 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 formatMetadataHelper
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function formatMetadataHelper( $metadataArray, $context = false ) {
$result = [
'visible' => [],
'collapsed' => []
];
Method getPageRangesByDimensions
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getPageRangesByDimensions( $pagesByDimensions ) {
$pageRangesByDimensions = [];
foreach ( $pagesByDimensions as $dimensions => $pageList ) {
$ranges = [];
Method addMeta
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected static function addMeta( &$array, $visibility, $type, $id, $value, $param = false ) {
Function removeBadFile
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function removeBadFile( $dstPath, $retval = 0 ) {
if ( file_exists( $dstPath ) ) {
$thumbstat = stat( $dstPath );
if ( $thumbstat['size'] == 0 || $retval != 0 ) {
$result = unlink( $dstPath );
- 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 doTransform
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
abstract public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 );