includes/controllers/class-llms-controller-checkout.php
File class-llms-controller-checkout.php
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
/**
* LLMS_Controller_Checkout
*
* @package LifterLMS/Controllers/Classes
Method switch_payment_source_setup
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function switch_payment_source_setup() {
$order_id = llms_filter_input( INPUT_POST, 'order_id', FILTER_SANITIZE_NUMBER_INT );
if ( ! $order_id ) {
return new WP_Error( 'switch-source-order-missing', __( 'Missing order information.', 'lifterlms' ), 'error' );
Method create_pending_order
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function create_pending_order() {
$verify = $this->verify_request( '_llms_checkout_nonce', self::ACTION_CREATE_PENDING_ORDER );
if ( ! $verify ) {
return $verify;
Function create_pending_order
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
public function create_pending_order() {
$verify = $this->verify_request( '_llms_checkout_nonce', self::ACTION_CREATE_PENDING_ORDER );
if ( ! $verify ) {
return $verify;
- 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
Open
return llms_add_notice( __( 'There was an error creating your order, please try again.', 'lifterlms' ), 'error' );
Avoid too many return
statements within this method. Open
Open
return new WP_Error( 'switch-source-action-invalid', __( 'Invalid action.', 'lifterlms' ), 'error' );
Avoid too many return
statements within this method. Open
Open
return compact( 'old_gateway', 'new_gateway', 'order' );
Function switch_payment_source_setup
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
private function switch_payment_source_setup() {
$order_id = llms_filter_input( INPUT_POST, 'order_id', FILTER_SANITIZE_NUMBER_INT );
if ( ! $order_id ) {
return new WP_Error( 'switch-source-order-missing', __( 'Missing order information.', 'lifterlms' ), '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"