File class-llms-form-field.php
has 461 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Setup and render form fields.
*
* @package LifterLMS/Classes
LLMS_Form_Field
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class LLMS_Form_Field {
/**
* Form Field Settings
*
Function prepare_options
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare_options( $raw ) {
$prepared = array();
foreach ( $raw 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
Method get_field_html
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_field_html() {
/**
* Allow 3rd parties to create custom field types or their own field HTML methods.
*
Function get_field_html
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function get_field_html() {
/**
* Allow 3rd parties to create custom field types or their own field HTML methods.
*
- 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 prepare_value
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare_value() {
// Never autoload passwords and or fields with an explicit value (except radio and checkbox).
if ( 'password' === $this->settings['type'] || ! empty( $this->settings['value'] && ! in_array( $this->settings['type'], array( 'checkbox', 'radio' ), true ) ) ) {
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 prepare_options
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function prepare_options( $raw ) {
$prepared = array();
foreach ( $raw as $key => $val ) {
Method prepare
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function prepare() {
if ( empty( $this->settings['id'] ) ) {
$this->settings['id'] = uniqid( 'llms-field-' );
}
Method explode_options_to_fields
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function explode_options_to_fields( $is_hidden = false ) {
$fields = array();
$value = ! empty( $this->settings['value'] ) || is_array( $this->settings['value'] )
? $this->settings['value']
Function prepare
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare() {
if ( empty( $this->settings['id'] ) ) {
$this->settings['id'] = uniqid( 'llms-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 prepare_value
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function prepare_value() {
// Never autoload passwords and or fields with an explicit value (except radio and checkbox).
if ( 'password' === $this->settings['type'] || ! empty( $this->settings['value'] && ! in_array( $this->settings['type'], array( 'checkbox', 'radio' ), true ) ) ) {
return;
Function explode_options_to_fields
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function explode_options_to_fields( $is_hidden = false ) {
$fields = array();
$value = ! empty( $this->settings['value'] ) || is_array( $this->settings['value'] )
? $this->settings['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 get_html_attributes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function get_html_attributes() {
$check = array(
'id',
'disabled',
- 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_html
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get_html() {
/**
* Short-circuit field HTML generation.
*
- 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 prepare_options_from_preset
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare_options_from_preset() {
$preset_id = $this->settings['options_preset'];
switch ( $preset_id ) {
case 'countries':
- 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"