File SQLManager.php
has 1127 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*******************************************************************************
Copyright 2009 Whole Foods Co-op
SQLManager
has 100 functions (exceeds 20 allowed). Consider refactoring. Open
class SQLManager
{
/**
Logging object (PSR-3)
*/
Method transfer
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function transfer($source_db,$select_query,$dest_db,$insert_query)
{
$result = $this->query($select_query,$source_db);
if (!$result) {
return false;
Function addConnection
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function addConnection($server,$type,$database,$username,$password='',$persistent=false,$new=false)
{
if (empty($type)) {
throw new Exception("Database type is required");
} elseif (strtolower($type) == 'postgres9') {
- 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 transfer
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function transfer($source_db,$select_query,$dest_db,$insert_query)
{
$result = $this->query($select_query,$source_db);
if (!$result) {
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
Method addConnection
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addConnection($server,$type,$database,$username,$password='',$persistent=false,$new=false)
{
if (empty($type)) {
throw new Exception("Database type is required");
} elseif (strtolower($type) == 'postgres9') {
Method fieldType
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fieldType($result_object,$index,$which_connection='')
{
if ($which_connection == '') {
$which_connection = $this->default_db;
}
Method query
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function query($query_text,$which_connection='',$params=false)
{
$con = $this->getNamedConnection($which_connection);
$result = (!is_object($con)) ? false : $con->Execute($query_text,$params);
Function query
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function query($query_text,$which_connection='',$params=false)
{
$con = $this->getNamedConnection($which_connection);
$result = (!is_object($con)) ? false : $con->Execute($query_text,$params);
- 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 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct($server,$type,$database,$username,$password='',$persistent=false, $new=false)
Method addConnection
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function addConnection($server,$type,$database,$username,$password='',$persistent=false,$new=false)
Function fieldType
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function fieldType($result_object,$index,$which_connection='')
{
if ($which_connection == '') {
$which_connection = $this->default_db;
}
- 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 columnToArray
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function columnToArray($col)
{
$info = array();
$type = strtoupper($col->type);
if (property_exists($col, 'max_length') && $col->max_length != -1 && substr($type, -3) != 'INT') {
- 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 getDSN
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function getDSN($server, $type, $database)
{
if ($this->isPDO($type)) {
$dsn = substr(strtolower($type), 4) . ':';
if (strstr($server, ':')) {
- 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 saveConnection
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function saveConnection($server, $type, $username, $password, $database)
Method connectAndCreate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function connectAndCreate($server, $type, $username, $password, $database)
Function getValue
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getValue($sql, $input_array=array(), $which_connection='')
{
$res = $this->execute($sql, $input_array, $which_connection);
if ($res && $this->numRows($res) > 0) {
$row = $this->fetchRow($res);
- 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 smartUpdate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function smartUpdate($table_name,$values,$where_clause,$which_connection='')
{
$which_connection = ($which_connection === '') ? $this->default_db : $which_connection;
$t_def = $this->tableDefinition($table_name, $which_connection);
- 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 setDefaultDB
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setDefaultDB($db_name)
{
/** verify connection **/
if (!is_string($db_name) || !isset($this->connections[$db_name])) {
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
Function smartInsert
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function smartInsert($table_name,$values,$which_connection='')
{
$which_connection = ($which_connection === '') ? $this->default_db : $which_connection;
$t_def = $this->tableDefinition($table_name, $which_connection);
- 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 getRow
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getRow($sql, $input_array=array(), $which_connection='')
{
$res = $this->execute($sql, $input_array, $which_connection);
if ($res && $this->numRows($res) > 0) {
$row = $this->fetchRow($res);
- 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 fetchArray
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function fetchArray($result_object,$which_connection='')
{
if (is_null($result_object)) return false;
if ($result_object === false) 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
Function executeAsTransaction
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function executeAsTransaction($query, $arg_sets, $which_connection='')
{
$which_connection = $which_connection === '' ? $this->default_db : $which_connection;
$ret = true;
$statement = $this->prepare($query, $which_connection);
- 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 columnBooleanProperty
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function columnBooleanProperty($col, $prop)
{
if (property_exists($col, $prop) && $col->$prop) {
return true;
} else if (property_exists($col, $prop) && !$col->$prop) {
- 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"