chippyash/Simple-Accounts

View on GitHub
src/Chippyash/SAccounts/Accountant.php

Summary

Maintainability
A
1 hr
Test Coverage

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

    protected function buildTree(Node $tree, \DOMNode $node, Chart $chart, array $accountTypes)
    {
        //create current node
        list($nominal, $type, $name, $id) = FFor::create()
            ->attributes(function () use ($node) {
Severity: Minor
Found in src/Chippyash/SAccounts/Accountant.php - About 1 hr to fix

    Avoid too many return statements within this method.
    Open

                    return new IntType($attributes->getNamedItem('id')->nodeValue);
    Severity: Major
    Found in src/Chippyash/SAccounts/Accountant.php - About 30 mins to fix

      The class Accountant has a coupling between objects value of 27. Consider to reduce the number of dependencies under 13.
      Open

      class Accountant
      {
          /**@+
           * Error strings
           */

      CouplingBetweenObjects

      Since: 1.1.0

      A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

      Example

      class Foo {
          /**
           * @var \foo\bar\X
           */
          private $x = null;
      
          /**
           * @var \foo\bar\Y
           */
          private $y = null;
      
          /**
           * @var \foo\bar\Z
           */
          private $z = null;
      
          public function setFoo(\Foo $foo) {}
          public function setBar(\Bar $bar) {}
          public function setBaz(\Baz $baz) {}
      
          /**
           * @return \SplObjectStorage
           * @throws \OutOfRangeException
           * @throws \InvalidArgumentException
           * @throws \ErrorException
           */
          public function process(\Iterator $it) {}
      
          // ...
      }

      Source https://phpmd.org/rules/design.html#couplingbetweenobjects

      Missing class import via use statement (line '63', column '28').
      Open

                      return new \DOMXPath($dom);

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Avoid variables with short names like $id. Configured minimum length is 3.
      Open

              list($nominal, $type, $name, $id) = FFor::create()

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      There are no issues that match your filters.

      Category
      Status