File ZipDirectoryReader.php
has 388 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* ZIP file directories reader, for the purposes of upload verification.
*
* This program is free software; you can redistribute it and/or modify
Method readCentralDirectory
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function readCentralDirectory( $offset, $size ) {
$block = $this->getBlock( $offset, $size );
$fixedInfo = [
'signature' => [ 'string', 4 ],
Function readCentralDirectory
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function readCentralDirectory( $offset, $size ) {
$block = $this->getBlock( $offset, $size );
$fixedInfo = [
'signature' => [ 'string', 4 ],
- 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 readEndOfCentralDirectoryRecord
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function readEndOfCentralDirectoryRecord() {
$info = [
'signature' => 4,
'disk' => 2,
'CD start disk' => 2,
Function unpack
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function unpack( $string, $struct, $offset = 0 ) {
$size = $this->getStructSize( $struct );
if ( $offset + $size > strlen( $string ) ) {
$this->error( 'zip-bad', 'unpack() would run past the end of the supplied string' );
}
- 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 unpack
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function unpack( $string, $struct, $offset = 0 ) {
$size = $this->getStructSize( $struct );
if ( $offset + $size > strlen( $string ) ) {
$this->error( 'zip-bad', 'unpack() would run past the end of the supplied string' );
}
Method readZip64EndOfCentralDirectoryRecord
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function readZip64EndOfCentralDirectoryRecord() {
if ( $this->eocdr64Locator['eocdr64 start disk'] != 0
|| $this->eocdr64Locator['number of disks'] != 0
) {
$this->error( 'zip-unsupported', 'more than one disk (in EOCDR64 locator)' );
Method execute
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function execute() {
$this->data = [];
if ( !$this->file ) {
return Status::newFatal( 'zip-file-open-error' );
}
Method getBlock
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getBlock( $start, $length = null ) {
$fileLength = $this->getFileLength();
if ( $start >= $fileLength ) {
$this->error( 'zip-bad', "getBlock() requested position $start, " .
"file length is $fileLength" );
Function findZip64CentralDirectory
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function findZip64CentralDirectory() {
// The spec is ambiguous about the exact rules of precedence between the
// ZIP64 headers and the original headers. Here we follow zip_util.c
// from OpenJDK 7.
$size = $this->eocdr['CD size'];
- 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 getSegment
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function getSegment( $segIndex ) {
if ( !isset( $this->buffer[$segIndex] ) ) {
$bytePos = $segIndex * self::SEGSIZE;
if ( $bytePos >= $this->getFileLength() ) {
$this->buffer[$segIndex] = '';
- 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 execute
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function execute() {
$this->data = [];
if ( !$this->file ) {
return Status::newFatal( 'zip-file-open-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 readEndOfCentralDirectoryRecord
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function readEndOfCentralDirectoryRecord() {
$info = [
'signature' => 4,
'disk' => 2,
'CD start disk' => 2,
- 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"