File FormBuilder.php
has 871 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* PepisCMS
*
FormBuilder
has 81 functions (exceeds 20 allowed). Consider refactoring. Open
class FormBuilder extends ContainerAware
{
const POST_ID_FIELD_NAME = 'form_builder_id';
/**
Function generate
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function generate()
{
$this->generateSetNoCacheHeaders();
// Default value
- 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 addFieldByDefinition
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function addFieldByDefinition($field)
{
if (!isset($field['field']) || !$field['field']) {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method generate
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate()
{
$this->generateSetNoCacheHeaders();
// Default value
Function generateHandleFileUpload
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function generateHandleFileUpload(&$save_array)
{
if (count($this->file_upload_fields) == 0) {
return;
}
- 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 addFieldByDefinition
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addFieldByDefinition($field)
{
if (!isset($field['field']) || !$field['field']) {
return false;
}
Method getFieldDefaults
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getFieldDefaults()
{
$defaults = array();
$defaults['field'] = false; // Field name
$defaults['label'] = false; // Field label
Function generateForeignKeyFetchObjectValues
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function generateForeignKeyFetchObjectValues($field)
{
// Resolving FOREIGN_KEY_MANY_TO_MANY relationship for a valid definition
if ($field['foreign_key_relationship_type'] == FormBuilder::FOREIGN_KEY_MANY_TO_MANY
&& $field['foreign_key_junction_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 deleteFileIfUserFlagSelected
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function deleteFileIfUserFlagSelected(&$save_array, $upload_field_name)
{
$wish_to_delete_file = $this->doesUserWishToDeleteFile($upload_field_name);
if ($wish_to_delete_file) {
$file_name_to_delete = $this->generateComputeFileField($upload_field_name);
- 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 generateHandleFileUpload
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function generateHandleFileUpload(&$save_array)
{
if (count($this->file_upload_fields) == 0) {
return;
}
Method addField
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function addField($field, $label = false, $type = false, $default_value = false, $rules = false, $values = false)
Function generateRecreateObjectFromSaveArray
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function generateRecreateObjectFromSaveArray($save_array)
{
// If there were no object, lets generate it from a dummy class to prevent useless errors
if (!$this->object) {
$this->object = new stdClass();
- 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 generateHandleForeignKeyManyToManyUpdate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function generateHandleForeignKeyManyToManyUpdate(&$save_array)
{
foreach ($this->fields as $field) {
// As we are already looping, lets do some magic
if ($field['foreign_key_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 generateForeignKeyFillFieldPossibleValues
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function generateForeignKeyFillFieldPossibleValues(&$field)
{
$should_fetch = false;
if (!$field['input_is_editable']) {
// is_array is required for multiple checkbox fields, etc - avoiding errors
- 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 handleForeignKeys
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function handleForeignKeys()
{
foreach ($this->fields as &$field) {
if ($field['foreign_key_table']) {
if ($this->getId()) {
- 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 generateForeignKeyManyToManyDoInsert
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function generateForeignKeyManyToManyDoInsert($save_id_values, $field, $where_conditions)
{
foreach ($save_id_values as $right_id) {
// There is no value specified, skip the cycle
if (!$right_id) {
- 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"