Showing 21 of 24 total issues
File Form.php
has 394 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Nickwest\EloquentForms;
use Illuminate\Support\Facades\Request;
Form
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
class Form
{
use HasFields, Themeable{
Themeable::setTheme as parentSetTheme;
}
Function setPostValues
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function setPostValues(array $post_data): void
{
foreach ($post_data as $field_name => $value) {
// We don't throw Exceptions here because post fields come from users and could be anything
// We just silently ignore invalid post fields
- 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 setAllFormValues
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function setAllFormValues(): void
{
foreach ($this->Form()->getFields() as $Field) {
// Use the Model Field's value if it has the field
if (isset($this->{$Field->getOriginalName()})) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function fromJson
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function fromJson(string $json): self
{
$array = json_decode($json);
foreach ($array as $key => $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 setMultipartIfNeeded
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function setMultipartIfNeeded()
{
if (isset($this->attributes->enctype)) {
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
Function isValid
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function isValid(): bool
{
$rules = [];
foreach ($this->Fields as $Field) {
$rules[$Field->getOriginalName()] = [];
- 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 isFormValid
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function isFormValid(): bool
{
// Add required fields to field_rules
$columns = $this->getAllColumns();
- 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 fromJson
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fromJson($json): void
{
$array = json_decode($json);
foreach ($array as $key => $value) {
switch ($key) {
Function getString
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getString(array $skip = []): string
{
$output = [];
$this->prepareClassAttribute();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function fromJson
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function fromJson($json): void
{
$array = json_decode($json);
foreach ($array as $key => $value) {
switch ($key) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function setTypes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function setTypes(array $types): void
{
foreach ($types as $field_name => $type) {
if (isset($this->Fields[$field_name])) {
// If it's a custom type, it'll be an object
- 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 getFieldReplacement
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getFieldReplacement(string $field, &$Object): string
{
$pattern = '/\{([a-zA-Z0-9_\?]+)\}/';
$results = [];
preg_match_all($pattern, $this->field_replacements[$field], $results, PREG_PATTERN_ORDER);
- 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 addMaxRule
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function addMaxRule($column, array &$rules)
{
// Set max length rule based on column length if available
if (isset($column['length']) && $column['length'] != '') {
// Find existing max: 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
Method renameSubmitButton
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function renameSubmitButton(string $name, string $value, string $new_name, string $new_value = null, string $new_label = null): void
Method setMargins
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function setMargins(\Maatwebsite\Excel\Sheet &$sheet, float $top = 0.7, float $right = 0.25, float $left = 0.25, float $bottom = 0.25): void
Function makeView
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function makeView(bool $prev_inline = false, bool $view_only = false): \Illuminate\View\View
{
if ($this->error_message) {
$this->attributes->addClass('error');
}
- 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 renameSubmitButton
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function renameSubmitButton(string $name, string $value, string $new_name, string $new_value = null, string $new_label = null): void
{
if (! isset($this->SubmitFields[$name.$value])) {
throw new InvalidFieldException($name.$value.' is not part of the Form');
}
- 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 getSQLEnumOptions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function getSQLEnumOptions(string $type, bool $nullable = false)
{
if (strpos($type, 'enum') !== 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
Function addSubform
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function addSubform(string $name, self $Form, string $before_field = ''): void
{
$this->addField($name);
$this->Fields[$name]->Subform = $Form;
- 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"