File Generic_model.php
has 622 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* PepisCMS
*
Generic_model
has 48 functions (exceeds 20 allowed). Consider refactoring. Open
class Generic_model extends PEPISCMS_Model implements EntitableInterface, MoveableInterface, AdvancedDataFeedableInterface
{
/**
* Database table name
*
Function move
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
public function move($id, $direction, $table = false, $constraint_field_name = false,
$item_order_field_name = 'item_order', $id_field_name = 'id')
{
// When no table is specified, taking table from the object
if (!$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
Method move
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function move($id, $direction, $table = false, $constraint_field_name = false,
$item_order_field_name = 'item_order', $id_field_name = 'id')
{
// When no table is specified, taking table from the object
if (!$table) {
Function applyFilters
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public static function applyFilters($db, $filters)
{
$allowed_conditions = array(
'eq' => '=',
'ne' => '!=',
- 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 journalingPersistPreSave
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
protected function journalingPersistPreSave($id, $data)
{
if (!$id || !$this->getJournalingIsEnabled()) {
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 getDistinctAssoc
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function getDistinctAssoc($column, $table = false, $pairs = false, $where_conditions = false)
{
if (!$table) {
$table = $this->getTable();
}
- 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 applyFilters
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function applyFilters($db, $filters)
{
$allowed_conditions = array(
'eq' => '=',
'ne' => '!=',
Method journalingPersistPreSave
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function journalingPersistPreSave($id, $data)
{
if (!$id || !$this->getJournalingIsEnabled()) {
return false;
}
Method getAdvancedFeed
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAdvancedFeed($columns, $offset, $rowcount, $order_by_column, $order, $filters, $extra_param)
{
if (!$columns || $columns == '*') { // TODO Check if $columns == '*' is ok
$columns = $this->getTable() . '.*';
}
Function applyWhere
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function applyWhere($db, $where_conditions)
{
if ($where_conditions) {
foreach ($where_conditions as $key => $condition) {
if (!$key || is_numeric($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
Method getDistinctAssoc
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getDistinctAssoc($column, $table = false, $pairs = false, $where_conditions = false)
{
if (!$table) {
$table = $this->getTable();
}
Function getAdvancedFeed
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getAdvancedFeed($columns, $offset, $rowcount, $order_by_column, $order, $filters, $extra_param)
{
if (!$columns || $columns == '*') { // TODO Check if $columns == '*' is ok
$columns = $this->getTable() . '.*';
}
- 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 getAdvancedFeed
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function getAdvancedFeed($columns, $offset, $rowcount, $order_by_column, $order, $filters, $extra_param)
Method move
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function move($id, $direction, $table = false, $constraint_field_name = false,
$item_order_field_name = 'item_order', $id_field_name = 'id')
Method getAssocPairs
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function getAssocPairs($key_column_name, $value_column_name, $table = false, $imitial_array = false,
$possible_keys = false, $where_conditions = false)
Method enableJournaling
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function enableJournaling($journaling_table = false, $include_fields = array(), $exclude_fields = array(),
$tag = null, $serialization_method = null, $unserialization_method = null)
Function journalingGetById
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function journalingGetById($id, $revision_id = false)
{
$row = $this->getById($id);
if ($revision_id && $this->getJournalingIsEnabled()) {
$row_archived = $this->db->select('data_serialized')
- 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 _saveByIdFilterData
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function _saveByIdFilterData($data, $accepted_post_fields)
{
// Reading fields that should be nullified when empty
$nullify_on_empty_post_fields = $this->getNullifyOnEmptyPostFields();
- 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 getAssocPairs
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getAssocPairs($key_column_name, $value_column_name, $table = false, $imitial_array = false,
$possible_keys = false, $where_conditions = false)
{
if (!$table) {
$table = $this->getTable();
- 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 setMappedFilterFields
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function setMappedFilterFields($fields_array)
{
if (!$fields_array || count($fields_array) == 0) {
$this->mapped_filter_fields = array();
return 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"