ekmungai/eloquent-ifrs

View on GitHub
src/Models/Transaction.php

Summary

Maintainability
B
5 hrs
Test Coverage
A
94%

File Transaction.php has 462 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

<?php

/**
 * Eloquent IFRS Accounting
 *
Severity: Minor
Found in src/Models/Transaction.php - About 7 hrs to fix

    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;
    Severity: Minor
    Found in src/Models/Transaction.php - About 5 hrs to fix

      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 {
      Severity: Minor
      Found in src/Models/Transaction.php - About 1 hr to fix

        Function getAmountAttribute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Wontfix

            public function getAmountAttribute(): float
            {
                $ledger = new Ledger();
                $amount = 0;
        
        
        Severity: Minor
        Found in src/Models/Transaction.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 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 {
        Severity: Minor
        Found in src/Models/Transaction.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 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");
                }
        Severity: Minor
        Found in src/Models/Transaction.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 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)
        Severity: Minor
        Found in src/Models/Transaction.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 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();
                }
        Severity: Minor
        Found in src/Models/Transaction.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 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);
                }
        Severity: Minor
        Found in src/Models/Transaction.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