ekmungai/eloquent-ifrs

View on GitHub
src/Models/Account.php

Summary

Maintainability
B
5 hrs
Test Coverage
A
100%

File Account.php has 330 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

<?php

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

    Account has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Account extends Model implements Recyclable, Segregatable
    {
        use Segregating;
        use SoftDeletes;
        use Recycling;
    Severity: Minor
    Found in src/Models/Account.php - About 2 hrs to fix

      Function sectionBalances has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Invalid

          public static function sectionBalances(
              array $accountTypes,
              $startDate = null,
              $endDate = null,
              $fullBalance = true,
      Severity: Minor
      Found in src/Models/Account.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 sectionBalances has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Wontfix

          public static function sectionBalances(
              array $accountTypes,
              $startDate = null,
              $endDate = null,
              $fullBalance = true,
      Severity: Minor
      Found in src/Models/Account.php - About 1 hr to fix

        Method transactionsQuery has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Wontfix

            public function transactionsQuery(Carbon $startDate, Carbon $endDate, int $currencyId = null)
            {
                $transactionsTable = config('ifrs.table_prefix') . 'transactions';
                $ledgerTable = config('ifrs.table_prefix') . 'ledgers';
        
        
        Severity: Minor
        Found in src/Models/Account.php - About 1 hr to fix

          Method openingBalance has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function openingBalance(int $year = null, int $currencyId = null): array
              {
                  $entity = $this->entity;
          
                  $balances = [$entity->currency_id => 0];
          Severity: Minor
          Found in src/Models/Account.php - About 1 hr to fix

            Function save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Wontfix

                public function save(array $options = []): bool
                {
            
                    if (Auth::user()) {
                        $entity = Auth::user()->entity;
            Severity: Minor
            Found in src/Models/Account.php - About 55 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

            Method sectionBalances has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    array $accountTypes,
                    $startDate = null,
                    $endDate = null,
                    $fullBalance = true,
                    Entity $entity = null
            Severity: Minor
            Found in src/Models/Account.php - About 35 mins to fix

              Function openingBalance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function openingBalance(int $year = null, int $currencyId = null): array
                  {
                      $entity = $this->entity;
              
                      $balances = [$entity->currency_id => 0];
              Severity: Minor
              Found in src/Models/Account.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 openingBalances has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function openingBalances(int $year, Entity $entity = null)
                  {
                      if (is_null($entity)) {
                          $entity = Auth::user()->entity;
                      }
              Severity: Minor
              Found in src/Models/Account.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