File Transaction.php
has 462 lines of code (exceeds 250 allowed). Consider refactoring. Wontfix
<?php
/**
* Eloquent IFRS Accounting
*
Transaction
has 41 functions (exceeds 20 allowed). Consider refactoring. Invalid
class Transaction extends Model implements Segregatable, Recyclable, Clearable, Assignable
{
use Segregating;
use SoftDeletes;
use Recycling;
Method save
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save(array $options = []): bool
{
if (is_null($this->entity_id)) {
$entity = Auth::user()->entity;
} else {
Function getAmountAttribute
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Wontfix
public function getAmountAttribute(): float
{
$ledger = new Ledger();
$amount = 0;
- 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 save
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function save(array $options = []): bool
{
if (is_null($this->entity_id)) {
$entity = Auth::user()->entity;
} else {
- 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 removeLineItem
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function removeLineItem(LineItem $lineItem): void
{
if (count($lineItem->ledgers) > 0) {
throw new PostedTransaction("remove LineItems from");
}
- 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 getVatAttribute
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getVatAttribute(): array
{
$vats = ['total' => 0];
foreach ($this->getLineItems() as $lineItem) {
foreach ($lineItem->vat as $type => $amount)
- 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 addAssigned
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Wontfix
public function addAssigned(array $toBeAssigned): void
{
if (!Transaction::find($toBeAssigned['id'])->is_posted) {
throw new UnpostedAssignment();
}
- 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 addLineItem
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function addLineItem(LineItem $lineItem): bool
{
if (in_array($lineItem->account->account_type, config('ifrs.single_currency')) && $lineItem->account->currency_id != $this->currency_id) {
throw new InvalidCurrency("Transaction", $lineItem->account);
}
- 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"