madbob/GASdottoNG

View on GitHub
code/app/Booking.php

Summary

Maintainability
D
2 days
Test Coverage

File Booking.php has 506 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
Severity: Major
Found in code/app/Booking.php - About 1 day to fix

    Booking has 44 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Booking extends Model
    {
        use HasFactory, GASModel, SluggableID, TracksUpdater, ModifiedTrait, PayableTrait, CreditableTrait, ReducibleTrait, Cachable;
    
        public $incrementing = false;
    Severity: Minor
    Found in code/app/Booking.php - About 6 hrs to fix

      Method getValue has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getValue($type, $with_friends, $force_recalculate = false)
          {
              $key = sprintf('%s_%s', $type, $with_friends ? 'friends' : 'nofriends');
      
              if ($force_recalculate) {
      Severity: Major
      Found in code/app/Booking.php - About 2 hrs to fix

        Function calculateModifiers has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function calculateModifiers($aggregate_data = null, $real = true)
            {
                $values = new Collection();
        
                $modifiers = $this->involvedModifiers();
        Severity: Minor
        Found in code/app/Booking.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

        Method getProductsWithFriendsAttribute has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getProductsWithFriendsAttribute()
            {
                return $this->innerCache('friends_products', function($obj) {
                    /*
                        Qui devo fare una copia di $this->products anziché usarlo
        Severity: Minor
        Found in code/app/Booking.php - About 1 hr to fix

          Function readProductQuantity has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private function readProductQuantity($product, $field, $friends_bookings)
              {
                  $combo = null;
          
                  if (is_a($product, VariantCombo::class)) {
          Severity: Minor
          Found in code/app/Booking.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 getBooked has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getBooked($product_id, $fallback = false)
              {
                  if (is_object($product_id)) {
                      $product = $product_id;
                      $product_id = $product_id->id;
          Severity: Minor
          Found in code/app/Booking.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 fixPayment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function fixPayment()
              {
                  $payment = $this->payment;
          
                  if ($payment) {
          Severity: Minor
          Found in code/app/Booking.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

          There are no issues that match your filters.

          Category
          Status