File class-llms-rest-enrollments-controller.php
has 624 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* REST Enrollments Controller.
*
* @package LLMS_REST
LLMS_REST_Enrollments_Controller
has 34 functions (exceeds 20 allowed). Consider refactoring. Open
class LLMS_REST_Enrollments_Controller extends LLMS_REST_Controller {
/**
* Route base.
*
Method get_objects_query
has 103 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_objects_query( $query_args, $request = null ) {
global $wpdb;
// Maybe limit the query results depending on the page param.
Method register_routes
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function register_routes() {
register_rest_route(
$this->namespace,
'/' . $this->rest_base,
Method get_item_schema_base
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_item_schema_base() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'students-enrollments',
Function update_item
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function update_item( $request ) {
$student_id = (int) $request['id'];
$post_id = (int) $request['post_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"
Further reading
Method update_item
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function update_item( $request ) {
$student_id = (int) $request['id'];
$post_id = (int) $request['post_id'];
Function get_objects_query
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function get_objects_query( $query_args, $request = null ) {
global $wpdb;
// Maybe limit the query results depending on the page param.
- 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_links
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function prepare_links( $enrollment, $request ) {
$links = array(
'self' => array(
'href' => rest_url(
Method create_item
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create_item( $request ) {
$user_id = (int) $request['id'];
$post_id = (int) $request['post_id'];
Function prepare_items_query
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare_items_query( $prepared_args = array(), $request = null ) {
$query_args = array();
foreach ( $prepared_args 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
Avoid too many return
statements within this method. Open
return llms_rest_server_error( __( 'The enrollment status could not be updated', 'lifterlms' ) );
Avoid too many return
statements within this method. Open
return $response;
Avoid too many return
statements within this method. Open
return $response;
Avoid too many return
statements within this method. Open
return $fields_update;
Avoid too many return
statements within this method. Open
return $fields_update;
Avoid too many return
statements within this method. Open
return $updated_date_created;
Avoid too many return
statements within this method. Open
return llms_rest_server_error( __( 'The enrollment creation date could not be updated', 'lifterlms' ) );
Function prepare_collection_items_for_response
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare_collection_items_for_response( $objects, $request ) {
$items = array();
foreach ( $objects as $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 create_item
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function create_item( $request ) {
$user_id = (int) $request['id'];
$post_id = (int) $request['post_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"