gocodebox/lifterlms

View on GitHub
includes/abstracts/abstract.llms.post.model.php

Summary

Maintainability
F
4 days
Test Coverage
B
85%

File abstract.llms.post.model.php has 646 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * LLMS_Post_Model abstract class file
 *
 * @package LifterLMS/Abstracts/Classes
Severity: Major
Found in includes/abstracts/abstract.llms.post.model.php - About 1 day to fix

    LLMS_Post_Model has 52 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class LLMS_Post_Model implements JsonSerializable {
    
        /**
         * Name of the post type as stored in the database
         * This will be prefixed (where applicable)
    Severity: Major
    Found in includes/abstracts/abstract.llms.post.model.php - About 7 hrs to fix

      Function parse_properties_to_set has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          private function parse_properties_to_set( $model_array ) {
      
              $llms_post = array(
                  'post' => array(),
                  'meta' => array(),
      Severity: Minor
      Found in includes/abstracts/abstract.llms.post.model.php - About 2 hrs to fix

      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 toArray has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function toArray() {
      
              $arr = array(
                  'id' => $this->get( 'id' ),
              );
      Severity: Minor
      Found in includes/abstracts/abstract.llms.post.model.php - About 2 hrs to fix

      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 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private function ___get( $key, $raw = false ) {
      
              // Force numeric id and prevent filtering on the id.
              if ( 'id' === $key ) {
      
      
      Severity: Minor
      Found in includes/abstracts/abstract.llms.post.model.php - About 2 hrs to fix

      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 parse_properties_to_set has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function parse_properties_to_set( $model_array ) {
      
              $llms_post = array(
                  'post' => array(),
                  'meta' => array(),
      Severity: Minor
      Found in includes/abstracts/abstract.llms.post.model.php - About 1 hr to fix

        Method ___get has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function ___get( $key, $raw = false ) {
        
                // Force numeric id and prevent filtering on the id.
                if ( 'id' === $key ) {
        
        
        Severity: Minor
        Found in includes/abstracts/abstract.llms.post.model.php - About 1 hr to fix

          Method toArray has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function toArray() {
          
                  $arr = array(
                      'id' => $this->get( 'id' ),
                  );
          Severity: Minor
          Found in includes/abstracts/abstract.llms.post.model.php - About 1 hr to fix

            Method scrub_field has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function scrub_field( $val, $type ) {
            
                    if ( is_string( $val ) && 'html' !== $type ) {
                        $val = wp_strip_all_tags( $val );
                    }
            Severity: Minor
            Found in includes/abstracts/abstract.llms.post.model.php - About 1 hr to fix

              Function update_meta_properties has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function update_meta_properties( $post_meta_properties, $allow_same_meta_value ) {
              
                      if ( empty( $post_meta_properties ) ) {
                          return;
                      }
              Severity: Minor
              Found in includes/abstracts/abstract.llms.post.model.php - About 1 hr to fix

              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 scrub_field has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function scrub_field( $val, $type ) {
              
                      if ( is_string( $val ) && 'html' !== $type ) {
                          $val = wp_strip_all_tags( $val );
                      }
              Severity: Minor
              Found in includes/abstracts/abstract.llms.post.model.php - About 1 hr to fix

              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 __construct has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function __construct( $model, $args = array() ) {
              
                      if ( 'new' === $model ) {
                          $model = $this->create( $args );
                          if ( ! is_wp_error( $model ) ) {
              Severity: Minor
              Found in includes/abstracts/abstract.llms.post.model.php - About 1 hr to fix

              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_image has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function get_image( $size = 'full', $key = '' ) {
                      if ( 'thumbnail' === $key && post_type_supports( $this->db_post_type, 'thumbnail' ) ) {
                          $url = get_the_post_thumbnail_url( $this->get( 'id' ), $size );
                      } else {
                          $id = $this->get( $key );
              Severity: Minor
              Found in includes/abstracts/abstract.llms.post.model.php - About 45 mins to fix

              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_price has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function get_price( $key, $price_args = array(), $format = 'html' ) {
              
                      $price = $this->get( $key );
              
                      // Handle empty or unset values gracefully.
              Severity: Minor
              Found in includes/abstracts/abstract.llms.post.model.php - About 35 mins to fix

              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 to_array_extra_blocks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function to_array_extra_blocks( $content ) {
              
                      $blocks = array();
              
                      foreach ( parse_blocks( $content ) as $block ) {
              Severity: Minor
              Found in includes/abstracts/abstract.llms.post.model.php - About 35 mins to fix

              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 toArrayCustom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function toArrayCustom( $arr ) {
              
                      // Build an array of keys that are registered or can be excluded as a custom field.
                      $props = array_keys( $this->get_properties() );
                      foreach ( $props as &$prop ) {
              Severity: Minor
              Found in includes/abstracts/abstract.llms.post.model.php - About 25 mins to fix

              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 set_bulk has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function set_bulk( $model_array, $wp_error = false, $allow_same_meta_value = false ) {
              
                      if ( empty( $model_array ) ) {
                          return $wp_error ? new WP_Error( 'empty_data', __( 'Empty data', 'lifterlms' ) ) : false;
                      }
              Severity: Minor
              Found in includes/abstracts/abstract.llms.post.model.php - About 25 mins to fix

              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

              There are no issues that match your filters.

              Category
              Status