tomaj/invoice-client

View on GitHub

Showing 10 of 10 total issues

Invoice has 38 functions (exceeds 20 allowed). Consider refactoring.
Open

class Invoice
{
    /** @var string */
    private $number;

Severity: Minor
Found in src/Invoice/Invoice.php - About 5 hrs to fix

    Function fromArray has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function fromArray(array $data)
        {
            $invoice = new Invoice();
            if (isset($data['number'])) {
                $invoice->setNumber($data['number']);
    Severity: Minor
    Found in src/Invoice/Invoice.php - About 3 hrs 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 __construct has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __construct($apiToken, $options = [])
        {
            $this->apiToken = $apiToken;
            $this->target = self::DEFAULT_TARGET;
    
    
    Severity: Minor
    Found in src/InvoiceApi.php - About 2 hrs 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 fromArray has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function fromArray(array $data)
        {
            $invoice = new Invoice();
            if (isset($data['number'])) {
                $invoice->setNumber($data['number']);
    Severity: Major
    Found in src/Invoice/Invoice.php - About 2 hrs to fix

      File Invoice.php has 260 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace Invoice;
      
      use Invoice\Exception\UnsupportedCurrencyException;
      Severity: Minor
      Found in src/Invoice/Invoice.php - About 2 hrs to fix

        Method __construct has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __construct($apiToken, $options = [])
            {
                $this->apiToken = $apiToken;
                $this->target = self::DEFAULT_TARGET;
        
        
        Severity: Minor
        Found in src/InvoiceApi.php - About 1 hr to fix

          Method fromArray has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function fromArray($data)
              {
                  $address = new Address();
                  if (isset($data['street'])) {
                      $address->setStreet($data['street']);
          Severity: Minor
          Found in src/Invoice/Address.php - About 1 hr to fix

            Method encodeInvoice has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function encodeInvoice(Invoice $invoice)
                {
                    $data = [
                        'id' => $invoice->getId(),
                        'number' => $invoice->getNumber(),
            Severity: Minor
            Found in src/Serializer.php - About 1 hr to fix

              Function fromArray has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function fromArray($data)
                  {
                      $address = new Address();
                      if (isset($data['street'])) {
                          $address->setStreet($data['street']);
              Severity: Minor
              Found in src/Invoice/Address.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

              Function fromArray has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function fromArray($data)
                  {
                      $item = new InvoiceItem();
                      if (isset($data['quantity'])) {
                          $item->setQuantity($data['quantity']);
              Severity: Minor
              Found in src/Invoice/InvoiceItem.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

              Severity
              Category
              Status
              Source
              Language