File class-llms-rest-controller.php
has 456 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Base REST Controller
*
* @package LifterLMS_REST/Abstracts
Function prepare_collection_query_search_args
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare_collection_query_search_args( $prepared, $request ) {
// Search?
if ( ! empty( $prepared['search'] ) ) {
- 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
LLMS_REST_Controller
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class LLMS_REST_Controller extends LLMS_REST_Controller_Stubs {
/**
* Endpoint namespace.
*
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_collection_params
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_collection_params() {
$query_params = parent::get_collection_params();
$query_params['context']['default'] = 'view';
Method prepare_collection_query_search_args
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function prepare_collection_query_search_args( $prepared, $request ) {
// Search?
if ( ! empty( $prepared['search'] ) ) {
Function add_header_pagination
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function add_header_pagination( $response, $pagination, $request ) {
$response->header( 'X-WP-Total', $pagination['total_results'] );
$response->header( 'X-WP-TotalPages', $pagination['total_pages'] );
- 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 $response;
Avoid too many return
statements within this method. Open
return $prepared;
Avoid too many return
statements within this method. Open
return $response;
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"