Function parseCSV
has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring. Open
public function parseCSV($path, $first_row_as_keys = true, $normalize_keys = true, $separator = false)
{
$lines = array();
$keys = array();
if (file_exists($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
Function generateCSV
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
public function generateCSV($feed, $headers = false, $file_name = false, $send = true, $separator = false, $print_headers = true)
{
if (!$separator) {
$separator = ',';
}
- 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 generateExcel
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
public function generateExcel($feed, $headers = false, $file_name = false, $send = true, $print_headers = true, $excel_type = Spreadsheet::EXCEL_XLS)
{
if (!$this->isFullyEnabled()) {
throw new \RuntimeException("PhpSpreadsheet is not enabled. Please refer to README.md");
}
- 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
File Spreadsheet.php
has 381 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* PepisCMS
*
Method generateExcel
has 114 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateExcel($feed, $headers = false, $file_name = false, $send = true, $print_headers = true, $excel_type = Spreadsheet::EXCEL_XLS)
{
if (!$this->isFullyEnabled()) {
throw new \RuntimeException("PhpSpreadsheet is not enabled. Please refer to README.md");
}
Function parseExcel
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function parseExcel($path, $first_row_as_keys = true, $normalize_keys = true)
{
if (!$this->isFullyEnabled()) {
throw new \RuntimeException("PhpSpreadsheet is not enabled. Please refer to README.md");
}
- 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 generateCSV
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateCSV($feed, $headers = false, $file_name = false, $send = true, $separator = false, $print_headers = true)
{
if (!$separator) {
$separator = ',';
}
Method parseCSV
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parseCSV($path, $first_row_as_keys = true, $normalize_keys = true, $separator = false)
{
$lines = array();
$keys = array();
if (file_exists($path)) {
Function generateXML
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function generateXML($feed, $headers = false, $file_name = false, $send = true, $root_name = false, $item_name = false)
{
if (!$file_name) {
$file_name = 'spreadsheet-' . date('Y-m-d-h-i-s') . '.xml';
}
- 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 generateXML
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generateXML($feed, $headers = false, $file_name = false, $send = true, $root_name = false, $item_name = false)
{
if (!$file_name) {
$file_name = 'spreadsheet-' . date('Y-m-d-h-i-s') . '.xml';
}
Method parseExcel
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parseExcel($path, $first_row_as_keys = true, $normalize_keys = true)
{
if (!$this->isFullyEnabled()) {
throw new \RuntimeException("PhpSpreadsheet is not enabled. Please refer to README.md");
}
Method generateExcel
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function generateExcel($feed, $headers = false, $file_name = false, $send = true, $print_headers = true, $excel_type = Spreadsheet::EXCEL_XLS)
Method generateCSV
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function generateCSV($feed, $headers = false, $file_name = false, $send = true, $separator = false, $print_headers = true)
Avoid deeply nested control flow statements. Open
for ($i = 0; $i < 99; $i++) {
$keys[] = $i;
}
Method generateXML
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function generateXML($feed, $headers = false, $file_name = false, $send = true, $root_name = false, $item_name = false)
Avoid deeply nested control flow statements. Open
if ($normalize_keys) {
foreach ($keys as &$key) {
$key = $this->normalizeKey($key);
}
}
Avoid deeply nested control flow statements. Open
if (!$key) {
$key = $ki;
}