File getid3.php
has 1242 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
Function HandleAllTags
has a Cognitive Complexity of 110 (exceeds 5 allowed). Consider refactoring. Open
public function HandleAllTags() {
// key name => array (tag name, character encoding)
static $tags;
if (empty($tags)) {
- 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 GetFileFormatArray
has 379 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function GetFileFormatArray() {
static $format_info = array();
if (empty($format_info)) {
$format_info = array(
Function __construct
has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring. Open
public function __construct() {
// Check for PHP version
$required_php_version = '5.0.5';
if (version_compare(PHP_VERSION, $required_php_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
Function analyze
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
public function analyze($filename) {
try {
if (!$this->openfile($filename)) {
return $this->info;
}
- 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 getHashdata
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function getHashdata($algorithm) {
switch ($algorithm) {
case 'md5':
case 'sha1':
break;
- 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 analyze
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function analyze($filename) {
try {
if (!$this->openfile($filename)) {
return $this->info;
}
Method HandleAllTags
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function HandleAllTags() {
// key name => array (tag name, character encoding)
static $tags;
if (empty($tags)) {
Function ChannelsBitratePlaytimeCalculations
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public function ChannelsBitratePlaytimeCalculations() {
// set channelmode on audio
if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
// ignore
- 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 __construct
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct() {
// Check for PHP version
$required_php_version = '5.0.5';
if (version_compare(PHP_VERSION, $required_php_version, '<')) {
Function CleanUp
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private function CleanUp() {
// remove possible empty keys
$AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate');
foreach ($AVpossibleEmptyKeys as $dummy => $key) {
- 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 saveAttachment
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function saveAttachment($name, $offset, $length, $image_mime=null) {
try {
// do not extract at all
if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_NONE) {
- 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 getHashdata
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getHashdata($algorithm) {
switch ($algorithm) {
case 'md5':
case 'sha1':
break;
Method openfile
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function openfile($filename) {
try {
if (!empty($this->startup_error)) {
throw new getid3_exception($this->startup_error);
}
Function openfile
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function openfile($filename) {
try {
if (!empty($this->startup_error)) {
throw new getid3_exception($this->startup_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
getID3
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class getID3
{
// public: Settings
public $encoding = 'UTF-8'; // CASE SENSITIVE! - i.e. (must be supported by iconv()). Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE
public $encoding_id3v1 = 'ISO-8859-1'; // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN' or 'CP1252'
Method CalculateCompressionRatioVideo
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function CalculateCompressionRatioVideo() {
if (empty($this->info['video'])) {
return false;
}
if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
Method saveAttachment
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function saveAttachment($name, $offset, $length, $image_mime=null) {
try {
// do not extract at all
if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_NONE) {
Function CalculateCompressionRatioVideo
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function CalculateCompressionRatioVideo() {
if (empty($this->info['video'])) {
return false;
}
if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
- 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 ChannelsBitratePlaytimeCalculations
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function ChannelsBitratePlaytimeCalculations() {
// set channelmode on audio
if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
// ignore
Function fseek
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function fseek($bytes, $whence=SEEK_SET) {
if ($this->data_string_flag) {
switch ($whence) {
case SEEK_SET:
$this->data_string_position = $bytes;
- 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 CleanUp
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function CleanUp() {
// remove possible empty keys
$AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate');
foreach ($AVpossibleEmptyKeys as $dummy => $key) {
Function ProcessAudioStreams
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function ProcessAudioStreams() {
if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
if (!isset($this->info['audio']['streams'])) {
foreach ($this->info['audio'] as $key => $value) {
if ($key != 'streams') {
- 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 CalculateReplayGain
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function CalculateReplayGain() {
if (isset($this->info['replay_gain'])) {
if (!isset($this->info['replay_gain']['reference_volume'])) {
$this->info['replay_gain']['reference_volume'] = (double) 89.0;
}
- 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 CalculateCompressionRatioAudio
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function CalculateCompressionRatioAudio() {
if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate']) || !is_numeric($this->info['audio']['sample_rate'])) {
return false;
}
$this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
- 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 deeply nested control flow statements. Open
if ((strtoupper($filesize) == '<DIR>') && (strtolower($filename) == strtolower($value))) {
$value = $shortname;
}
Avoid too many return
statements within this method. Open
return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.');
Avoid too many return
statements within this method. Open
return $this->error($errormessage);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $this->error('Format not supported, module "'.$determined_format['include'].'" is corrupt.');
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return $this->info;
Avoid too many return
statements within this method. Open
return false;
Function setOption
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function setOption($optArray) {
if (!is_array($optArray) || empty($optArray)) {
return false;
}
foreach ($optArray as $opt => $val) {
- 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 GetFileFormat
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function GetFileFormat(&$filedata, $filename='') {
// this function will determine the format of a file based on usually
// the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
// and in the case of ISO CD image, 6 bytes offset 32kb from the start
// of the file).
- 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"