File Booking.php
has 506 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
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;
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) {
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();
- 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 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
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)) {
- 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 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;
- 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 fixPayment
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function fixPayment()
{
$payment = $this->payment;
if ($payment) {
- 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"