File xpdoobject.class.php
has 1763 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* Copyright 2010-2015 by MODX, LLC.
*
* This file is part of xPDO.
Function set
has a Cognitive Complexity of 177 (exceeds 5 allowed). Consider refactoring. Open
public function set($k, $v= null, $vType= '') {
$set= false;
$callback= '';
$callable= !empty($vType) && is_callable($vType, false, $callback) ? true : false;
if (!$callable && isset($this->_fieldMeta[$k]['callback'])) {
- 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 save
has a Cognitive Complexity of 161 (exceeds 5 allowed). Consider refactoring. Open
public function save($cacheFlag= null) {
if ($this->isLazy()) {
$this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Attempt to save lazy object: ' . print_r($this->toArray('', true), 1));
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 get
has a Cognitive Complexity of 156 (exceeds 5 allowed). Consider refactoring. Open
public function get($k, $format = null, $formatTemplate= null) {
$value= null;
if (is_array($k)) {
$lazy = array_intersect($k, $this->_lazy);
if ($lazy) {
- 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 remove
has a Cognitive Complexity of 100 (exceeds 5 allowed). Consider refactoring. Open
public function remove(array $ancestors= array ()) {
$result= false;
$pk= $this->getPrimaryKey();
if ($pk && $this->xpdo->getConnection(array(xPDO::OPT_CONN_MUTABLE => true))) {
$primaryKey = $pk;
- 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 fromArray
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
public function fromArray($fldarray, $keyPrefix= '', $setPrimaryKeys= false, $rawValues= false, $adhocValues= false) {
if (is_array($fldarray)) {
$pkSet= false;
$generatedKey= false;
foreach ($fldarray as $key => $val) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getGraph
has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring. Open
public function getGraph($graph = true, $criteria = null, $cacheFlag = true) {
/* graph is true, get all relations to max depth */
if ($graph === true) {
$graph = $this->xpdo->getGraph($this->_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 addOne
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
public function addOne(& $obj, $alias= '') {
$added= false;
if (is_object($obj)) {
if (empty ($alias)) {
if ($obj->_alias == $obj->_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 _saveRelatedObjects
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
protected function _saveRelatedObjects() {
$saved= 0;
if (!empty ($this->_relatedObjects)) {
foreach ($this->_relatedObjects as $alias => $ro) {
$objects= array ();
- 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
xPDOObject
has 55 functions (exceeds 20 allowed). Consider refactoring. Open
class xPDOObject {
/**
* A convenience reference to the xPDO object.
* @var xPDO
* @access public
Function load
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
public static function load(xPDO & $xpdo, $className, $criteria, $cacheFlag= true) {
$instance= null;
$fromCache= false;
if ($className= $xpdo->loadClass($className)) {
if (!is_object($criteria)) {
- 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 save
has 177 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save($cacheFlag= null) {
if ($this->isLazy()) {
$this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Attempt to save lazy object: ' . print_r($this->toArray('', true), 1));
return false;
}
Function _loadRows
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
public static function & _loadRows(& $xpdo, $className, $criteria) {
$rows= null;
if ($criteria->prepare()) {
if ($xpdo->getDebug() === true) $xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Attempting to execute query using PDO statement object: " . print_r($criteria->sql, true) . print_r($criteria->bindings, true));
$tstart= microtime(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 addMany
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
public function addMany(& $obj, $alias= '') {
$added= false;
if (!is_array($obj)) {
if (is_object($obj)) {
if (empty ($alias)) {
- 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 _getRelatedObjectsByFK
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
protected function & _getRelatedObjectsByFK($alias, $criteria= null, $cacheFlag= true) {
$collection= array ();
if (isset($this->_relatedObjects[$alias]) && (is_object($this->_relatedObjects[$alias]) || (is_array($this->_relatedObjects[$alias]) && !empty ($this->_relatedObjects[$alias])))) {
$collection= & $this->_relatedObjects[$alias];
} else {
- 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 set
has 149 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function set($k, $v= null, $vType= '') {
$set= false;
$callback= '';
$callable= !empty($vType) && is_callable($vType, false, $callback) ? true : false;
if (!$callable && isset($this->_fieldMeta[$k]['callback'])) {
Function toArray
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
public function toArray($keyPrefix= '', $rawValues= false, $excludeLazy= false, $includeRelated= false) {
$objArray= null;
if (is_array($this->_fields)) {
$keys= array_keys($this->_fields);
if (!$excludeLazy && $this->isLazy()) {
- 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 getSelectColumns
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
public static function getSelectColumns(xPDO & $xpdo, $className, $tableAlias= '', $columnPrefix= '', $columns= array (), $exclude= false) {
$columnarray= array ();
$aColumns= $xpdo->getFields($className);
if ($aColumns) {
if (!empty ($tableAlias)) {
- 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 get
has 135 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get($k, $format = null, $formatTemplate= null) {
$value= null;
if (is_array($k)) {
$lazy = array_intersect($k, $this->_lazy);
if ($lazy) {
Function _saveRelatedObject
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
protected function _saveRelatedObject(& $obj, $fkMeta) {
$saved= false;
$local= $fkMeta['local'];
$foreign= $fkMeta['foreign'];
$cardinality= $fkMeta['cardinality'];
- 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 remove
has 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function remove(array $ancestors= array ()) {
$result= false;
$pk= $this->getPrimaryKey();
if ($pk && $this->xpdo->getConnection(array(xPDO::OPT_CONN_MUTABLE => true))) {
$primaryKey = $pk;
Function getIterator
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function getIterator($alias, $criteria= null, $cacheFlag= true) {
$iterator = false;
$fkMeta= $this->getFKDefinition($alias);
if ($fkMeta) {
$fkCriteria = isset($fkMeta['criteria']) && isset($fkMeta['criteria']['foreign']) ? $fkMeta['criteria']['foreign'] : 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 _loadInstance
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public static function _loadInstance(& $xpdo, $className, $criteria, $row) {
$rowPrefix= '';
if (is_object($criteria) && $criteria instanceof xPDOQuery) {
$alias = $criteria->getAlias();
$actualClass = $criteria->getClass();
- 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 getPrimaryKey
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function getPrimaryKey($validateCompound= true) {
$value= null;
if ($pk= $this->getPK()) {
if (is_array($pk)) {
foreach ($pk as $k) {
- 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 _setRaw
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
protected function _setRaw($key, $val) {
$set = false;
if ($val === null) {
$this->_fields[$key] = null;
$set = 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 getFKClass
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public function getFKClass($k) {
$fkclass= null;
$k = $this->getField($k, true);
if (is_string($k)) {
if (!empty ($this->_aggregates)) {
- 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 loadCollection
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static function loadCollection(xPDO & $xpdo, $className, $criteria= null, $cacheFlag= true) {
$objCollection= array ();
$fromCache = false;
if (!$className= $xpdo->loadClass($className)) return $objCollection;
$rows= 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 _setRaw
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _setRaw($key, $val) {
$set = false;
if ($val === null) {
$this->_fields[$key] = null;
$set = true;
Function _loadCollectionInstance
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function _loadCollectionInstance(xPDO & $xpdo, array & $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag=true) {
$loaded = false;
if ($obj= xPDOObject :: _loadInstance($xpdo, $className, $criteria, $row)) {
if (($cacheKey= $obj->getPrimaryKey()) && !$obj->isLazy()) {
if (is_array($cacheKey)) {
- 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 getGraph
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getGraph($graph = true, $criteria = null, $cacheFlag = true) {
/* graph is true, get all relations to max depth */
if ($graph === true) {
$graph = $this->xpdo->getGraph($this->_class);
}
Method _loadRows
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function & _loadRows(& $xpdo, $className, $criteria) {
$rows= null;
if ($criteria->prepare()) {
if ($xpdo->getDebug() === true) $xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Attempting to execute query using PDO statement object: " . print_r($criteria->sql, true) . print_r($criteria->bindings, true));
$tstart= microtime(true);
Method _loadInstance
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function _loadInstance(& $xpdo, $className, $criteria, $row) {
$rowPrefix= '';
if (is_object($criteria) && $criteria instanceof xPDOQuery) {
$alias = $criteria->getAlias();
$actualClass = $criteria->getClass();
Function loadCollectionGraph
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static function loadCollectionGraph(xPDO & $xpdo, $className, $graph, $criteria, $cacheFlag) {
$objCollection = array();
if ($query= $xpdo->newQuery($className, $criteria, $cacheFlag)) {
$query = $xpdo->addDerivativeCriteria($className, $query);
$query->bindGraph($graph);
- 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 addOne
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addOne(& $obj, $alias= '') {
$added= false;
if (is_object($obj)) {
if (empty ($alias)) {
if ($obj->_alias == $obj->_class) {
Method fromArray
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fromArray($fldarray, $keyPrefix= '', $setPrimaryKeys= false, $rawValues= false, $adhocValues= false) {
if (is_array($fldarray)) {
$pkSet= false;
$generatedKey= false;
foreach ($fldarray as $key => $val) {
Function getOne
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function & getOne($alias, $criteria= null, $cacheFlag= true) {
$object= null;
if ($fkdef= $this->getFKDefinition($alias)) {
$k= $fkdef['local'];
$fk= $fkdef['foreign'];
- 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 14 (exceeds 5 allowed). Consider refactoring. Open
public function __construct(xPDO & $xpdo) {
$this->xpdo= & $xpdo;
$this->container= $xpdo->config['dbname'];
$this->_class= get_class($this);
$pos= strrpos($this->_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 load
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function load(xPDO & $xpdo, $className, $criteria, $cacheFlag= true) {
$instance= null;
$fromCache= false;
if ($className= $xpdo->loadClass($className)) {
if (!is_object($criteria)) {
Method getSelectColumns
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getSelectColumns(xPDO & $xpdo, $className, $tableAlias= '', $columnPrefix= '', $columns= array (), $exclude= false) {
$columnarray= array ();
$aColumns= $xpdo->getFields($className);
if ($aColumns) {
if (!empty ($tableAlias)) {
Method toArray
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toArray($keyPrefix= '', $rawValues= false, $excludeLazy= false, $includeRelated= false) {
$objArray= null;
if (is_array($this->_fields)) {
$keys= array_keys($this->_fields);
if (!$excludeLazy && $this->isLazy()) {
Method _getRelatedObjectsByFK
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function & _getRelatedObjectsByFK($alias, $criteria= null, $cacheFlag= true) {
$collection= array ();
if (isset($this->_relatedObjects[$alias]) && (is_object($this->_relatedObjects[$alias]) || (is_array($this->_relatedObjects[$alias]) && !empty ($this->_relatedObjects[$alias])))) {
$collection= & $this->_relatedObjects[$alias];
} else {
Function _getAliases
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function _getAliases($class, $limit = 0) {
$aliases = array();
$limit = intval($limit);
$array = array('aggregates' => $this->_aggregates, 'composites' => $this->_composites);
foreach ($array as $relType => $relations) {
- 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 addMany
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addMany(& $obj, $alias= '') {
$added= false;
if (!is_array($obj)) {
if (is_object($obj)) {
if (empty ($alias)) {
Method loadCollection
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function loadCollection(xPDO & $xpdo, $className, $criteria= null, $cacheFlag= true) {
$objCollection= array ();
$fromCache = false;
if (!$className= $xpdo->loadClass($className)) return $objCollection;
$rows= false;
Method _saveRelatedObject
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _saveRelatedObject(& $obj, $fkMeta) {
$saved= false;
$local= $fkMeta['local'];
$foreign= $fkMeta['foreign'];
$cardinality= $fkMeta['cardinality'];
Method _saveRelatedObjects
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _saveRelatedObjects() {
$saved= 0;
if (!empty ($this->_relatedObjects)) {
foreach ($this->_relatedObjects as $alias => $ro) {
$objects= array ();
Method __construct
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(xPDO & $xpdo) {
$this->xpdo= & $xpdo;
$this->container= $xpdo->config['dbname'];
$this->_class= get_class($this);
$pos= strrpos($this->_class, '_');
Function addFieldAlias
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function addFieldAlias($field, $alias) {
$added = false;
if (array_key_exists($field, $this->_fields)) {
if (!array_key_exists($alias, $this->_fields)) {
$this->_fields[$alias] =& $this->_fields[$field];
- 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 loadCollectionGraph
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function loadCollectionGraph(xPDO & $xpdo, $className, $graph, $criteria, $cacheFlag) {
$objCollection = array();
if ($query= $xpdo->newQuery($className, $criteria, $cacheFlag)) {
$query = $xpdo->addDerivativeCriteria($className, $query);
$query->bindGraph($graph);
Method getPrimaryKey
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getPrimaryKey($validateCompound= true) {
$value= null;
if ($pk= $this->getPK()) {
if (is_array($pk)) {
foreach ($pk as $k) {
Function __get
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function __get($name) {
if ($this->getOption(xPDO::OPT_HYDRATE_FIELDS) && array_key_exists($name, $this->_fields)) {
return $this->_fields[$name];
} elseif ($this->getOption(xPDO::OPT_HYDRATE_RELATED_OBJECTS)) {
if (array_key_exists($name, $this->_composites)) {
- 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 __set
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function __set($name, $value) {
if ($this->getOption(xPDO::OPT_HYDRATE_FIELDS) && array_key_exists($name, $this->_fields)) {
return $this->_setRaw($name, $value);
} elseif ($this->getOption(xPDO::OPT_HYDRATE_RELATED_OBJECTS)) {
if (array_key_exists($name, $this->_composites)) {
- 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 getIterator
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getIterator($alias, $criteria= null, $cacheFlag= true) {
$iterator = false;
$fkMeta= $this->getFKDefinition($alias);
if ($fkMeta) {
$fkCriteria = isset($fkMeta['criteria']) && isset($fkMeta['criteria']['foreign']) ? $fkMeta['criteria']['foreign'] : null;
Consider simplifying this complex logical expression. Open
if (in_array($this->_fieldMeta[$_k]['phptype'], array ('datetime', 'timestamp')) && !empty($this->_fieldMeta[$_k]['attributes']) && $this->_fieldMeta[$_k]['attributes'] == 'ON UPDATE CURRENT_TIMESTAMP') {
$this->_fields[$_k]= date('Y-m-d H:i:s');
continue;
}
elseif ($fieldValue === null || $fieldValue === 'NULL') {
Function setDirty
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function setDirty($key= '') {
if (empty($key)) {
foreach (array_keys($this->_fieldMeta) as $fIdx => $fieldKey) {
$this->setDirty($fieldKey);
}
- 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 _loadCollectionInstance
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function _loadCollectionInstance(xPDO & $xpdo, array & $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag=true) {
Avoid deeply nested control flow statements. Open
if ($ts !== false && !empty($value)) {
if (is_string($format) && !empty ($format)) {
if (strpos($format, 're:') === 0) {
$value= date('Y-m-d H:i:s', $ts);
if (!empty ($formatTemplate) && is_string($formatTemplate)) {
Avoid deeply nested control flow statements. Open
if (is_string($value) && strlen($value) > 1) {
$value= $this->xpdo->fromJSON($value, true);
}
Avoid deeply nested control flow statements. Open
if (is_string($format) && !empty ($format)) {
if (strpos($format, 're:') === 0) {
if (!empty ($formatTemplate) && is_string($formatTemplate)) {
$value= preg_replace(substr($format, 3), $formatTemplate, $value);
}
Avoid deeply nested control flow statements. Open
if ($cardinality == 'many') {
$newPk= $obj->getPrimaryKey();
if (is_array($newPk)) $newPk= implode('-', $newPk);
if ($pk != $newPk) {
$this->_relatedObjects[$alias][$newPk]= $obj;
Function getValidator
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getValidator() {
if (!is_object($this->_validator)) {
$validatorClass = $this->xpdo->loadClass('validation.xPDOValidator', XPDO_CORE_PATH, true, true);
if ($derivedClass = $this->getOption(xPDO::OPT_VALIDATOR_CLASS, null, '')) {
if ($derivedClass = $this->xpdo->loadClass($derivedClass, '', 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
Avoid deeply nested control flow statements. Open
if (is_string($value)) {
$value= unserialize($value);
}
Avoid deeply nested control flow statements. Open
if (is_string($format) && !empty ($format)) {
if (strpos($format, 're:') === 0) {
if (!empty ($formatTemplate) && is_string($formatTemplate)) {
$value= preg_replace(substr($format, 3), $formatTemplate, $value);
}
Avoid deeply nested control flow statements. Open
if (in_array($childPK, $ancestors[$composite['class']])) {
continue;
}
Avoid deeply nested control flow statements. Open
if ($ts !== false && !empty($value)) {
if (is_string($format) && !empty ($format)) {
if (strpos($format, 're:') === 0) {
$value= date('Y-m-d', $ts);
if (!empty ($formatTemplate) && is_string($formatTemplate)) {
Method getSelectColumns
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function getSelectColumns(xPDO & $xpdo, $className, $tableAlias= '', $columnPrefix= '', $columns= array (), $exclude= false) {
Avoid deeply nested control flow statements. Open
if (is_string($format) && !empty ($format)) {
if (strpos($format, 're:') === 0) {
if (!empty ($formatTemplate) && is_string($formatTemplate)) {
$value= preg_replace(substr($format, 3), $formatTemplate, $value);
}
Avoid deeply nested control flow statements. Open
if ($pkGenerated) {
$this->_fields[$this->getPK()]= $this->xpdo->lastInsertId();
}
Avoid deeply nested control flow statements. Open
if (is_array($childPK)) {
$childPK = implode('|', $childPK);
}
Method fromArray
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function fromArray($fldarray, $keyPrefix= '', $setPrimaryKeys= false, $rawValues= false, $adhocValues= false) {
Method fromJSON
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function fromJSON($jsonSource, $keyPrefix= '', $setPrimaryKeys= false, $rawValues= false, $adhocValues= false) {
Method addValidationRule
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function addValidationRule($field, $name, $type, $rule, array $parameters= array()) {
Method loadCollectionGraph
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function loadCollectionGraph(xPDO & $xpdo, $className, $graph, $criteria, $cacheFlag) {
Function removeValidationRules
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function removeValidationRules($field = null, array $rules = array()) {
if (!$this->_validationLoaded) $this->_loadValidation();
if (empty($rules) && is_string($field)) {
unset($this->_validationRules[$this->getField($field)]);
} elseif (empty($rules) && is_null($field)) {
- 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 addValidationRule
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function addValidationRule($field, $name, $type, $rule, array $parameters= array()) {
$field = $this->getField($field);
if (is_string($field)) {
if (!$this->_validationLoaded) $this->_loadValidation();
if (!isset($this->_validationRules[$field])) $this->_validationRules[$field]= array();
- 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 _loadValidation
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function _loadValidation($reload= false) {
if (!$this->_validationLoaded || $reload == true) {
$validation= $this->xpdo->getValidationRules($this->_class);
$this->_validationLoaded= true;
foreach ($validation as $column => $rules) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return $this->getOne($name);
Avoid too many return
statements within this method. Open
return $this->addOne($value, $name);
Function validate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function validate(array $options = array()) {
$validated= false;
if ($validator= $this->getValidator()) {
$validated= $this->_validator->validate($options);
if ($this->xpdo->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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!is_array($row)) {
if ($xpdo->getDebug() === true) $xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Fetched empty result set from statement: " . print_r($criteria->sql, true) . " with bindings: " . print_r($criteria->bindings, true));
} else {
$instance= xPDOObject :: _loadInstance($xpdo, $className, $criteria, $row);
if (is_object($instance)) {
- 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 283.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
public static function _loadCollectionInstance(xPDO & $xpdo, array & $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag=true) {
$loaded = false;
if ($obj= xPDOObject :: _loadInstance($xpdo, $className, $criteria, $row)) {
if (($cacheKey= $obj->getPrimaryKey()) && !$obj->isLazy()) {
if (is_array($cacheKey)) {
- 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 272.
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 3 locations. Consider refactoring. Open
if ($criteria === null) {
$criteria= array($fkMeta['foreign'] => $this->get($fkMeta['local']));
if ($fkCriteria !== null) {
$criteria= array($fkCriteria, $criteria);
}
- 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 215.
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 3 locations. Consider refactoring. Open
if ($criteria === null) {
$criteria= array($fkMeta['foreign'] => $this->get($fkMeta['local']));
if ($fkCriteria !== null) {
$criteria = array($fkCriteria, $criteria);
}
- 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 215.
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 3 locations. Consider refactoring. Open
if ($criteria === null) {
$query= array($fkMeta['foreign'] => $this->get($fkMeta['local']));
if ($fkCriteria !== null) {
$query= array($fkCriteria, $query);
}
- 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 215.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (is_array ($rows)) {
foreach ($rows as $row) {
xPDOObject :: _loadCollectionInstance($xpdo, $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag);
}
} elseif (is_object($rows)) {
- 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 176.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
} else {
$tstart= microtime(true);
if (!$criteria->stmt->execute()) {
$xpdo->queryTime += microtime(true) - $tstart;
$xpdo->executedQueries++;
- 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 143.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if ($xpdo->getManager() && $xpdo->manager->createObjectContainer($className)) {
$tstart= microtime(true);
if (!$criteria->stmt->execute()) {
$xpdo->queryTime += microtime(true) - $tstart;
$xpdo->executedQueries++;
- 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 143.
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
protected function _getDataType($key) {
$type= 'text';
$actualKey = $this->getField($key, true);
if ($actualKey !== false && isset($this->_fieldMeta[$actualKey]['dbtype'])) {
$type= strtolower($this->_fieldMeta[$actualKey]['dbtype']);
- 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 126.
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
protected function _getPHPType($key) {
$type= 'string';
$actualKey = $this->getField($key, true);
if ($actualKey !== false && isset($this->_fieldMeta[$actualKey]['phptype'])) {
$type= strtolower($this->_fieldMeta[$actualKey]['phptype']);
- 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 126.
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
Identical blocks of code found in 3 locations. Consider refactoring. Open
if (is_string($format) && !empty ($format)) {
if (strpos($format, 're:') === 0) {
if (!empty ($formatTemplate) && is_string($formatTemplate)) {
$value= preg_replace(substr($format, 3), $formatTemplate, $value);
}
- 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 109.
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
Identical blocks of code found in 3 locations. Consider refactoring. Open
if (is_string($format) && !empty ($format)) {
if (strpos($format, 're:') === 0) {
if (!empty ($formatTemplate) && is_string($formatTemplate)) {
$value= preg_replace(substr($format, 3), $formatTemplate, $value);
}
- 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 109.
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
Identical blocks of code found in 3 locations. Consider refactoring. Open
if (is_string($format) && !empty ($format)) {
if (strpos($format, 're:') === 0) {
if (!empty ($formatTemplate) && is_string($formatTemplate)) {
$value= preg_replace(substr($format, 3), $formatTemplate, $value);
}
- 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 109.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (preg_match('/int/i', $dbtype)) {
if (strtolower($vType) == 'integer' || is_int($v) || $v == '0') {
$ts= (integer) $v;
} else {
$ts= strtotime($v);
- 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 104.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (preg_match('/int/i', $dbtype)) {
if (strtolower($vType) == 'integer' || is_int($v) || $v == '0') {
$ts= (integer) $v;
} else {
$ts= strtotime($v);
- 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 104.
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