File model.llms.student.php
has 832 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Student Model
*
* @package LifterLMS/Models/Classes
LLMS_Student
has 49 functions (exceeds 20 allowed). Consider refactoring. Open
class LLMS_Student extends LLMS_Abstract_User_Data {
use LLMS_Trait_Student_Awards;
/**
Function get_progress
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function get_progress( $object_id, $type = 'course', $use_cache = true ) {
$ret = 0;
$cache_key = sprintf( '%1$s_%2$d_progress', $type, $object_id );
$cached = $use_cache ? $this->get( $cache_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 update_completion_status
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private function update_completion_status( $status, $object_id, $object_type, $trigger = 'unspecified' ) {
$student_id = $this->get_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 get_enrollments
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_enrollments( $post_type = 'course', $args = array() ) {
global $wpdb;
$args = wp_parse_args(
Method update_completion_status
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function update_completion_status( $status, $object_id, $object_type, $trigger = 'unspecified' ) {
$student_id = $this->get_id();
/**
Method get_completed_courses
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_completed_courses( $args = array() ) {
global $wpdb;
$args = array_merge(
Method get_progress
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_progress( $object_id, $type = 'course', $use_cache = true ) {
$ret = 0;
$cache_key = sprintf( '%1$s_%2$d_progress', $type, $object_id );
$cached = $use_cache ? $this->get( $cache_key ) : '';
Function get_overall_grade
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function get_overall_grade( $use_cache = true ) {
$grade = null;
// Attempt to pull from the cache first.
- 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_enrollment_order
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_enrollment_order( $product_id ) {
// If a lesson id was passed in, cascade up to the course for order retrieval.
if ( 'lesson' === get_post_type( $product_id ) ) {
$lesson = new LLMS_Lesson( $product_id );
Method get_orders
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_orders( $params = array() ) {
$params = wp_parse_args(
$params,
array(
Function unenroll
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function unenroll( $product_id, $trigger = 'any', $new_status = 'expired' ) {
// Can only unenroll those that are a currently enrolled.
if ( ! $this->is_enrolled( $product_id, 'all', false ) ) {
return false;
- 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 is_enrolled
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function is_enrolled( $product_ids = null, $relation = 'all', $use_cache = true ) {
// Assume enrollment unless we find otherwise.
$ret = true;
- 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_overall_grade
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_overall_grade( $use_cache = true ) {
$grade = null;
// Attempt to pull from the cache first.
Method enroll
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function enroll( $product_id, $trigger = 'unspecified' ) {
/**
* Fires before a user is enrolled into a course or membership.
*
Method get_enrollment_status
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_enrollment_status( $product_id, $use_cache = true ) {
$status = false;
$product_type = get_post_type( $product_id );
Method unenroll
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function unenroll( $product_id, $trigger = 'any', $new_status = 'expired' ) {
// Can only unenroll those that are a currently enrolled.
if ( ! $this->is_enrolled( $product_id, 'all', false ) ) {
return false;
Function get_overall_progress
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function get_overall_progress( $use_cache = true ) {
$progress = null;
// Attempt to pull from the cache first.
- 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 insert_incompletion_postmeta
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function insert_incompletion_postmeta( $object_id, $trigger = 'unspecified' ) {
global $wpdb;
// Add '_is_complete' to the user postmeta table for object.
Method get_overall_progress
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_overall_progress( $use_cache = true ) {
$progress = null;
// Attempt to pull from the cache first.
Function get_enrollment_order
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function get_enrollment_order( $product_id ) {
// If a lesson id was passed in, cascade up to the course for order retrieval.
if ( 'lesson' === get_post_type( $product_id ) ) {
$lesson = new LLMS_Lesson( $product_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
Function remove_membership_level
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function remove_membership_level( $membership_id, $status = 'expired', $delete = false ) {
// Remove the user from the membership level.
$membership_levels = $this->get_membership_levels();
$key = array_search( $membership_id, $membership_levels );
- 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 enroll
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function enroll( $product_id, $trigger = 'unspecified' ) {
/**
* Fires before a user is enrolled into a course or membership.
*
- 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_enrollments
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get_enrollments( $post_type = 'course', $args = array() ) {
global $wpdb;
$args = wp_parse_args(
- 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 delete_enrollment
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function delete_enrollment( $product_id, $trigger = 'any' ) {
// Assume we can't delete the enrollment.
$delete = false;
- 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_enrollment_status
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function get_enrollment_status( $product_id, $use_cache = true ) {
$status = false;
$product_type = get_post_type( $product_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
Function get_enrollment_trigger_id
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function get_enrollment_trigger_id( $product_id ) {
$trigger = $this->get_enrollment_trigger( $product_id );
$id = false;
if ( $trigger && false !== strpos( $trigger, '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"