File xpdo.class.php
has 1972 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* OpenExpedio ("xPDO") is an ultra-light, PHP 5.2+ compatible ORB (Object-
* Relational Bridge) library based around PDO (http://php.net/pdo/).
*
Function toCache
has a Cognitive Complexity of 120 (exceeds 5 allowed). Consider refactoring. Open
public function toCache($signature, $object, $lifetime= 0, $options = array()) {
$result= false;
if ($this->getCacheManager()) {
if ($this->getOption(xPDO::OPT_CACHE_DB, $options)) {
if ($lifetime === true) {
- 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 getPK
has a Cognitive Complexity of 108 (exceeds 5 allowed). Consider refactoring. Open
public function getPK($className) {
$pk= null;
if (strcasecmp($className, 'xPDOObject') !== 0) {
if ($actualClassName= $this->loadClass($className)) {
if (isset ($this->map[$actualClassName]['indexes'])) {
- 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
xPDO
has 89 functions (exceeds 20 allowed). Consider refactoring. Open
class xPDO {
/**#@+
* Constants
*/
const OPT_AUTO_CREATE_TABLES = 'auto_create_tables';
Function fromCache
has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring. Open
public function fromCache($signature, $class= '', $options= array()) {
$result= null;
if ($this->getOption(xPDO::OPT_CACHE_DB, $options)) {
if ($signature && $this->getCacheManager()) {
$sig= '';
- 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 loadClass
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
public function loadClass($fqn, $path= '', $ignorePkg= false, $transient= false) {
if (empty($fqn)) {
$this->log(xPDO::LOG_LEVEL_ERROR, "No class specified for loadClass");
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 updateCollection
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
public function updateCollection($className, array $set, $criteria= null) {
$affected = false;
if ($this->getConnection(array(xPDO::OPT_CONN_MUTABLE => true))) {
$query = $this->newQuery($className);
if ($query && !empty($set)) {
- 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 removeObject
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
public function removeObject($className, $criteria) {
$removed= false;
if ($this->getConnection(array(xPDO::OPT_CONN_MUTABLE => true))) {
if ($this->getCount($className, $criteria) === 1) {
if ($query= $this->newQuery($className)) {
- 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 escSplit
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public static function escSplit($char, $str, $escToken = '`', $limit = 0) {
$split= array();
$charPos = strpos($str, $char);
if ($charPos !== false) {
if ($charPos === 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 getIndexMeta
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
public function getIndexMeta($className) {
$indices= array();
if ($className= $this->loadClass($className)) {
if ($ancestry= $this->getAncestry($className)) {
for ($i= count($ancestry) -1; $i >= 0; $i--) {
- 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 __construct
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($dsn, $username= '', $password= '', $options= array(), $driverOptions= null) {
try {
$this->config = $this->initConfig($options);
$this->setLogLevel($this->getOption('log_level', null, xPDO::LOG_LEVEL_FATAL, true));
$this->setLogTarget($this->getOption('log_target', null, XPDO_CLI_MODE ? 'ECHO' : 'HTML', true));
- 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 getTableName
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function getTableName($className, $includeDb= false) {
$table= null;
if ($className= $this->loadClass($className)) {
if (isset ($this->map[$className]['table'])) {
$table= $this->map[$className]['table'];
- 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 parseBindings
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function parseBindings($sql, $bindings) {
if (!empty($sql) && !empty($bindings)) {
$bound = array();
foreach ($bindings as $k => $param) {
if (!is_array($param)) {
- 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 getValidationRules
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public function getValidationRules($className) {
$rules= array();
if ($className= $this->loadClass($className)) {
if ($ancestry= $this->getAncestry($className)) {
for ($i= count($ancestry) - 1; $i >= 0; $i--) {
- 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 toCache
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toCache($signature, $object, $lifetime= 0, $options = array()) {
$result= false;
if ($this->getCacheManager()) {
if ($this->getOption(xPDO::OPT_CACHE_DB, $options)) {
if ($lifetime === true) {
Function _log
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
protected function _log($level, $msg, $target= '', $def= '', $file= '', $line= '') {
if ($level !== xPDO::LOG_LEVEL_FATAL && $level > $this->logLevel && $this->_debug !== true) {
return;
}
if (empty ($target)) {
- 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 getFieldAliases
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function getFieldAliases($className) {
$fieldAliases= array ();
if ($className= $this->loadClass($className)) {
if ($ancestry= $this->getAncestry($className)) {
for ($i= count($ancestry) - 1; $i >= 0; $i--) {
- 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 getFieldMeta
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function getFieldMeta($className, $includeExtended = false) {
$fieldMeta= array ();
if ($className= $this->loadClass($className)) {
if ($ancestry= $this->getAncestry($className)) {
for ($i= count($ancestry) - 1; $i >= 0; $i--) {
- 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 getFields
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function getFields($className) {
$fields= array ();
if ($className= $this->loadClass($className)) {
if ($ancestry= $this->getAncestry($className)) {
for ($i= count($ancestry) - 1; $i >= 0; $i--) {
- 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 getComposites
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function getComposites($className) {
$composites= array ();
if ($className= $this->loadClass($className)) {
if ($ancestry= $this->getAncestry($className)) {
for ($i= count($ancestry) - 1; $i >= 0; $i--) {
- 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 getAggregates
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function getAggregates($className) {
$aggregates= array ();
if ($className= $this->loadClass($className)) {
if ($ancestry= $this->getAncestry($className)) {
for ($i= count($ancestry) - 1; $i >= 0; $i--) {
- 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 removeCollection
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function removeCollection($className, $criteria) {
$removed= false;
if ($this->getConnection(array(xPDO::OPT_CONN_MUTABLE => true))) {
if ($query= $this->newQuery($className)) {
$query->command('DELETE');
- 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 getOption
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function getOption($key, $options = null, $default = null, $skipEmpty = false) {
$option = null;
if (is_string($key) && !empty($key)) {
$found = false;
if (isset($options[$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 addDerivativeCriteria
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function addDerivativeCriteria($className, $criteria) {
if ($criteria instanceof xPDOQuery && !isset($this->map[$className]['table'])) {
if (isset($this->map[$className]['fields']['class_key']) && !empty($this->map[$className]['fields']['class_key'])) {
$criteria->where(array('class_key' => $this->map[$className]['fields']['class_key']));
if ($this->getDebug() === true) {
- 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 getPKType
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function getPKType($className, $pk= false) {
$pktype= null;
if ($actualClassName= $this->loadClass($className)) {
if (!$pk)
$pk= $this->getPK($actualClassName);
- 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 _log
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _log($level, $msg, $target= '', $def= '', $file= '', $line= '') {
if ($level !== xPDO::LOG_LEVEL_FATAL && $level > $this->logLevel && $this->_debug !== true) {
return;
}
if (empty ($target)) {
Function getConnection
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function &getConnection(array $options = array()) {
$conn =& $this->connection;
$mutable = $this->getOption(xPDO::OPT_CONN_MUTABLE, $options, null);
if (!($conn instanceof xPDOConnection) || ($mutable !== null && (($mutable == true && !$conn->isMutable()) || ($mutable == false && $conn->isMutable())))) {
if (!empty($this->_connections)) {
- 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 _loadClass
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
protected function _loadClass($class, $fqn, $included= false, $path= '', $transient= false) {
if (empty($path)) $path= XPDO_CORE_PATH;
if (!$included) {
/* turn to filesystem path and enforce all lower-case paths and filenames */
$fqcn= str_replace('.', '/', $fqn) . '.class.php';
- 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 getTableMeta
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function getTableMeta($className) {
$tableMeta= null;
if ($className= $this->loadClass($className)) {
if (isset ($this->map[$className]['tableMeta'])) {
$tableMeta= $this->map[$className]['tableMeta'];
- 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 setPackageMeta
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function setPackageMeta($pkg, $path = '') {
$set = false;
if (is_string($pkg) && !empty($pkg)) {
$pkgPath = str_replace('.', '/', $pkg);
$mapFile = $path . $pkgPath . '/metadata.' . $this->config['dbtype'] . '.php';
- 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 connect
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function connect($driverOptions = array()) {
if ($this->pdo === null) {
if (is_array($driverOptions) && !empty($driverOptions)) {
$this->config['driverOptions']= $driverOptions + $this->config['driverOptions'];
}
- 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 getCount
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function getCount($className, $criteria = null) {
$count = 0;
if ($query = $this->newQuery($className, $criteria)) {
$stmt = null;
$expr = '*';
- 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 getInherit
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function getInherit($className) {
$inherit= false;
if ($className= $this->loadClass($className)) {
if (isset ($this->map[$className]['inherit'])) {
$inherit= $this->map[$className]['inherit'];
- 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 getTableClass
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function getTableClass($className) {
$tableClass= null;
if ($className= $this->loadClass($className)) {
if (isset ($this->map[$className]['table'])) {
$tableClass= $className;
- 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 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($dsn, $username= '', $password= '', $options= array(), $driverOptions= null) {
try {
$this->config = $this->initConfig($options);
$this->setLogLevel($this->getOption('log_level', null, xPDO::LOG_LEVEL_FATAL, true));
$this->setLogTarget($this->getOption('log_target', null, XPDO_CLI_MODE ? 'ECHO' : 'HTML', true));
Function getObjectLoader
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function getObjectLoader($className, $method) {
$loader = false;
if (isset($this->config[xPDO::OPT_LOADER_CLASSES]) && is_array($this->config[xPDO::OPT_LOADER_CLASSES])) {
if ($ancestry = $this->getAncestry($className, true)) {
if ($callbacks = array_intersect($ancestry, $this->config[xPDO::OPT_LOADER_CLASSES])) {
- 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 loadClass
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function loadClass($fqn, $path= '', $ignorePkg= false, $transient= false) {
if (empty($fqn)) {
$this->log(xPDO::LOG_LEVEL_ERROR, "No class specified for loadClass");
return false;
}
Function bind
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function bind($bindings= array (), $byValue= true, $cacheFlag= false) {
if (!empty ($bindings)) {
$this->bindings= array_merge($this->bindings, $bindings);
}
if (is_object($this->stmt) && $this->stmt && !empty ($this->bindings)) {
- 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 getService
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function &getService($name, $class= '', $path= '', $params= array ()) {
$service= null;
if (!isset ($this->services[$name]) || !is_object($this->services[$name])) {
if (empty ($class) && isset ($this->config[$name . '.class'])) {
$class= $this->config[$name . '.class'];
- 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 fromCache
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fromCache($signature, $class= '', $options= array()) {
$result= null;
if ($this->getOption(xPDO::OPT_CACHE_DB, $options)) {
if ($signature && $this->getCacheManager()) {
$sig= '';
Method getPK
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getPK($className) {
$pk= null;
if (strcasecmp($className, 'xPDOObject') !== 0) {
if ($actualClassName= $this->loadClass($className)) {
if (isset ($this->map[$actualClassName]['indexes'])) {
Method parseBindings
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parseBindings($sql, $bindings) {
if (!empty($sql) && !empty($bindings)) {
$bound = array();
foreach ($bindings as $k => $param) {
if (!is_array($param)) {
Function getPackage
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function getPackage($className) {
$package= '';
if ($className= $this->loadClass($className)) {
if (isset($this->map[$className]['package'])) {
$package= $this->map[$className]['package'];
- 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 updateCollection
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateCollection($className, array $set, $criteria= null) {
$affected = false;
if ($this->getConnection(array(xPDO::OPT_CONN_MUTABLE => true))) {
$query = $this->newQuery($className);
if ($query && !empty($set)) {
Function getFKDefinition
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function getFKDefinition($parentClass, $alias) {
$def= null;
$parentClass= $this->loadClass($parentClass);
if ($parentClass && $alias) {
if ($aggregates= $this->getAggregates($parentClass)) {
- 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 escSplit
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function escSplit($char, $str, $escToken = '`', $limit = 0) {
$split= array();
$charPos = strpos($str, $char);
if ($charPos !== false) {
if ($charPos === 0) {
Function addPackage
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function addPackage($pkg= '', $path= '', $prefix= null) {
$added= false;
if (is_string($pkg) && !empty($pkg)) {
if (!is_string($path) || empty($path)) {
$this->log(xPDO::LOG_LEVEL_ERROR, "Invalid path specified for package: {$pkg}; using default xpdo model path: " . XPDO_CORE_PATH . 'om/');
- 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 sanitizePKCriteria
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function sanitizePKCriteria($className, &$criteria) {
if (is_scalar($criteria)) {
$pkType = $this->getPKType($className);
if (is_string($pkType)) {
$pk = $this->getPK($className);
- 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 fromJSON
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function fromJSON($src, $asArray= true) {
$decoded= '';
if ($src) {
if (!function_exists('json_decode')) {
if (@ include_once (XPDO_CORE_PATH . 'json/JSON.php')) {
- 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 call
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function call($class, $method, array $args = array(), $transient = false) {
$return = null;
$callback = '';
if ($transient) {
$className = $this->loadClass($class, '', false, true);
- 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 getGraph
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function getGraph($className, $depth= 3, &$parents = array(), &$visited = array()) {
$graph = array();
$className = $this->loadClass($className);
if ($className && $depth > 0) {
$depth--;
- 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 getTableName
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTableName($className, $includeDb= false) {
$table= null;
if ($className= $this->loadClass($className)) {
if (isset ($this->map[$className]['table'])) {
$table= $this->map[$className]['table'];
Method removeObject
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function removeObject($className, $criteria) {
$removed= false;
if ($this->getConnection(array(xPDO::OPT_CONN_MUTABLE => true))) {
if ($this->getCount($className, $criteria) === 1) {
if ($query= $this->newQuery($className)) {
Method getCount
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getCount($className, $criteria = null) {
$count = 0;
if ($query = $this->newQuery($className, $criteria)) {
$stmt = null;
$expr = '*';
Function getInstance
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function getInstance($id = null, $config = null, $forceNew = false) {
$instances =& self::$instances;
if (is_null($id)) {
if (!is_null($config) || $forceNew || empty($instances)) {
$id = uniqid(__CLASS__);
- 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 __construct
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function __construct(& $xpdo, array $options= array()) {
$this->xpdo =& $xpdo;
if (isset($options['class'])) {
$this->class = $this->xpdo->loadClass($options['class']);
}
- 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 connect
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function connect($driverOptions = array()) {
if ($this->pdo === null) {
if (is_array($driverOptions) && !empty($driverOptions)) {
$this->config['driverOptions']= $driverOptions + $this->config['driverOptions'];
}
Method getService
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function &getService($name, $class= '', $path= '', $params= array ()) {
$service= null;
if (!isset ($this->services[$name]) || !is_object($this->services[$name])) {
if (empty ($class) && isset ($this->config[$name . '.class'])) {
$class= $this->config[$name . '.class'];
Method getOption
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getOption($key, $options = null, $default = null, $skipEmpty = false) {
$option = null;
if (is_string($key) && !empty($key)) {
$found = false;
if (isset($options[$key])) {
Method removeCollection
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function removeCollection($className, $criteria) {
$removed= false;
if ($this->getConnection(array(xPDO::OPT_CONN_MUTABLE => true))) {
if ($query= $this->newQuery($className)) {
$query->command('DELETE');
Function getDebugBacktrace
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getDebugBacktrace() {
$backtrace= array ();
foreach (debug_backtrace() as $levelKey => $levelElement) {
foreach ($levelElement as $traceKey => $traceElement) {
if ($traceKey == 'object' && $traceElement instanceof xPDOObject) {
- 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 log
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function log($level, $msg, $target= '', $def= '', $file= '', $line= '') {
Method _log
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function _log($level, $msg, $target= '', $def= '', $file= '', $line= '') {
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(xPDO &$xpdo, $dsn, $username= '', $password= '', $options= array(), $driverOptions= array()) {
Avoid deeply nested control flow statements. Open
if ($descendantClass && isset($this->map[$descendantClass]['indexes'])) {
$indices= array_merge($indices, array_diff_key($this->map[$descendantClass]['indexes'], $indices));
}
Avoid deeply nested control flow statements. Open
while ($key= next($exploded)) {
$sigKey[]= $key;
}
Avoid deeply nested control flow statements. Open
if (empty($sigClass)) $sigClass = $signature->getTableClass();
Avoid deeply nested control flow statements. Open
if (empty($sigKey)) {
while ($key= next($exploded)) {
$sigKey[]= $key;
}
}
Avoid deeply nested control flow statements. Open
if ($signature instanceof xPDOQuery) {
$signature->construct();
if (empty($sigClass)) $sigClass= $signature->getTableClass();
}
Avoid deeply nested control flow statements. Open
if ($this->getDebug() === true) {
$this->log(xPDO::LOG_LEVEL_DEBUG, "Removing all cache objects of class {$gClass}: " . ($removed ? 'successful' : 'failed'));
}
Avoid deeply nested control flow statements. Open
if (isset ($v['index']) && isset ($v['phptype']) && $v['index'] == 'pk') {
$pk[$k]= $k;
}
Avoid deeply nested control flow statements. Open
if (empty($sigClass) || $sigClass !== $class) {
$sigClass= $class;
}
Avoid deeply nested control flow statements. Open
while (!is_callable($loader) && $loaderClass = next($callbacks)) {
$loader = array($loaderClass, $method);
}
Avoid deeply nested control flow statements. Open
if (isset ($this->map[$ancestorClassName]['fieldMeta'][$k]['phptype'])) {
if (isset ($v['primary']) && $v['primary'] == true) {
$pk[$k]= $k;
}
}
Consider simplifying this complex logical expression. Open
if ($target=='FILE' && $this->getCacheManager()) {
$filename = isset($targetOptions['filename']) ? $targetOptions['filename'] : 'error.log';
$filepath = isset($targetOptions['filepath']) ? $targetOptions['filepath'] : $this->getCachePath() . xPDOCacheManager::LOG_DIR;
$this->cacheManager->writeFile($filepath . $filename, $content, 'a');
} elseif ($target=='ARRAY' && isset($targetOptions['var']) && is_array($targetOptions['var'])) {
Consider simplifying this complex logical expression. Open
if (!($conn instanceof xPDOConnection) || ($mutable !== null && (($mutable == true && !$conn->isMutable()) || ($mutable == false && $conn->isMutable())))) {
if (!empty($this->_connections)) {
shuffle($this->_connections);
$conn = reset($this->_connections);
while ($conn) {
Method addConnection
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function addConnection($dsn, $username= '', $password= '', array $options= array(), $driverOptions= null) {
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct($dsn, $username= '', $password= '', $options= array(), $driverOptions= null) {
Method _loadClass
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function _loadClass($class, $fqn, $included= false, $path= '', $transient= false) {
Method getSelectColumns
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function getSelectColumns($className, $tableAlias= '', $columnPrefix= '', $columns= array (), $exclude= false) {
Function toJSON
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function toJSON($array) {
$encoded= '';
if (is_array ($array)) {
if (!function_exists('json_encode')) {
if (@ include_once (XPDO_CORE_PATH . 'json/JSON.php')) {
- 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 __construct
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(& $xpdo, $sql= '', $bindings= array (), $cacheFlag= false) {
$this->xpdo= & $xpdo;
$this->cacheFlag= $cacheFlag;
if (is_string($sql) && !empty ($sql)) {
$this->sql= $sql;
- 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 parseDSN
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function parseDSN($string) {
$result= array ();
$pos= strpos($string, ':');
$result['dbtype']= strtolower(substr($string, 0, $pos));
$parameters= explode(';', substr($string, ($pos +1)));
- 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 getAncestry
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getAncestry($className, $includeSelf= true) {
$ancestry= array ();
if ($actualClassName= $this->loadClass($className)) {
$ancestor= $actualClassName;
if ($includeSelf) {
- 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 newObject
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function newObject($className, $fields= array ()) {
$instance= null;
if ($className= $this->loadClass($className)) {
$className .= '_' . $this->config['dbtype'];
if ($instance= new $className ($this)) {
- 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 getDriver
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getDriver() {
if ($this->driver === null || !$this->driver instanceof xPDODriver) {
$loaded= include_once(XPDO_CORE_PATH . 'om/' . $this->config['dbtype'] . '/xpdodriver.class.php');
if ($loaded) {
$driverClass = 'xPDODriver_' . $this->config['dbtype'];
- 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 getDescendants
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getDescendants($className) {
$descendants = array();
if (isset($this->classMap[$className])) {
$descendants = $this->classMap[$className];
if ($descendants) {
- 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 getManager
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getManager() {
if ($this->manager === null || !$this->manager instanceof xPDOManager) {
$loaded= include_once(XPDO_CORE_PATH . 'om/' . $this->config['dbtype'] . '/xpdomanager.class.php');
if ($loaded) {
$managerClass = 'xPDOManager_' . $this->config['dbtype'];
- 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 fetch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function fetch() {
$row = $this->stmt->fetch(PDO::FETCH_ASSOC);
if (is_array($row) && !empty($row)) {
$instance = $this->xpdo->call($this->class, '_loadInstance', array(& $this->xpdo, $this->class, $this->alias, $row));
if ($instance === null) {
- 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 getValue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getValue($stmt, $column= null) {
$value = null;
if (is_object($stmt) && $stmt instanceof PDOStatement) {
$tstart = microtime(true);
if ($stmt->execute()) {
- 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
Similar blocks of code found in 4 locations. Consider refactoring. Open
public function getFields($className) {
$fields= array ();
if ($className= $this->loadClass($className)) {
if ($ancestry= $this->getAncestry($className)) {
for ($i= count($ancestry) - 1; $i >= 0; $i--) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 240.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
public function getAggregates($className) {
$aggregates= array ();
if ($className= $this->loadClass($className)) {
if ($ancestry= $this->getAncestry($className)) {
for ($i= count($ancestry) - 1; $i >= 0; $i--) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 240.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
public function getComposites($className) {
$composites= array ();
if ($className= $this->loadClass($className)) {
if ($ancestry= $this->getAncestry($className)) {
for ($i= count($ancestry) - 1; $i >= 0; $i--) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 240.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 4 locations. Consider refactoring. Open
public function getFieldAliases($className) {
$fieldAliases= array ();
if ($className= $this->loadClass($className)) {
if ($ancestry= $this->getAncestry($className)) {
for ($i= count($ancestry) - 1; $i >= 0; $i--) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 240.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (isset($this->map[$ancestor]['package']) && isset($this->packages[$this->map[$ancestor]['package']]['prefix'])) {
$table= $this->packages[$this->map[$ancestor]['package']]['prefix'] . $table;
} else {
$table= $this->getOption(xPDO::OPT_TABLE_PREFIX, null, '') . $table;
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 106.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (isset($this->map[$className]['package']) && isset($this->packages[$this->map[$className]['package']]['prefix'])) {
$table= $this->packages[$this->map[$className]['package']]['prefix'] . $table;
} else {
$table= $this->getOption(xPDO::OPT_TABLE_PREFIX, null, '') . $table;
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 106.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
exit ('[' . date('Y-m-d H:i:s') . '] (' . $this->_getLogLevel($level) . $def . $file . $line . ') ' . $msg . "\n" . ($this->getDebug() === true ? '<pre>' . "\n" . print_r(debug_backtrace(), true) . "\n" . '</pre>' : ''));
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 103.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76