vindi/vindi-woocommerce

View on GitHub
src/services/Webhooks.php

Summary

Maintainability
C
1 day
Test Coverage

File Webhooks.php has 362 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace VindiPaymentGateways;

use WC_Subscriptions_Manager;
Severity: Minor
Found in src/services/Webhooks.php - About 4 hrs to fix

    The class VindiWebhooks has an overall complexity of 74 which is very high. The configured complexity threshold is 50.
    Open

    class VindiWebhooks
    {
      /**
       * @var VindiSettings
       */
    Severity: Minor
    Found in src/services/Webhooks.php by phpmd

    VindiWebhooks has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class VindiWebhooks
    {
      /**
       * @var VindiSettings
       */
    Severity: Minor
    Found in src/services/Webhooks.php - About 3 hrs to fix

      Method bill_paid has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function bill_paid($data)
          {
              try {
                  if (empty($data->bill->subscription)) {
                    $order = $this->find_order_by_id($data->bill->code);
      Severity: Minor
      Found in src/services/Webhooks.php - About 1 hr to fix

        Function bill_paid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function bill_paid($data)
            {
                try {
                    if (empty($data->bill->subscription)) {
                      $order = $this->find_order_by_id($data->bill->code);
        Severity: Minor
        Found in src/services/Webhooks.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

        Avoid using undefined variables such as '$subscriptionn_id' which will lead to PHP notices.
        Open

              throw new Exception(sprintf(__('Pedido da assinatura #%s para o ciclo #%s não encontrado!', VINDI), $subscriptionn_id, $cycle), 2);
        Severity: Minor
        Found in src/services/Webhooks.php by phpmd

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

        Source https://phpmd.org/rules/cleancode.html#undefinedvariable

        The method bill_paid uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                    } else {
                        $vindi_subscription_id = $data->bill->subscription->id;
                        $cycle = $data->bill->period->cycle;
                        $order = $this->find_order_by_subscription_and_cycle($vindi_subscription_id, $cycle);
                    }
        Severity: Minor
        Found in src/services/Webhooks.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        Avoid using static access to class '\WC_Subscriptions_Manager' in method 'subscription_renew'.
        Open

            WC_Subscriptions_Manager::prepare_renewal($subscription->id);
        Severity: Minor
        Found in src/services/Webhooks.php by phpmd

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        The method bill_canceled uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

              } else {
                $vindi_subscription_id = $data->bill->subscription->id;
                $cycle = $data->bill->period->cycle;
                $order = $this->find_order_by_subscription_and_cycle($vindi_subscription_id, $cycle);
              }
        Severity: Minor
        Found in src/services/Webhooks.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

        Source https://phpmd.org/rules/cleancode.html#elseexpression

        Avoid unused parameters such as '$data'.
        Open

          private function test($data)
        Severity: Minor
        Found in src/services/Webhooks.php by phpmd

        UnusedFormalParameter

        Since: 0.2

        Avoid passing parameters to methods or constructors and then not using those parameters.

        Example

        class Foo
        {
            private function bar($howdy)
            {
                // $howdy is not used
            }
        }

        Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

        The method handle() contains an exit expression.
        Open

                    die('invalid access token');
        Severity: Minor
        Found in src/services/Webhooks.php by phpmd

        ExitExpression

        Since: 0.2

        An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

        Example

        class Foo {
            public function bar($param)  {
                if ($param === 42) {
                    exit(23);
                }
            }
        }

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

        The method handle() contains an exit expression.
        Open

                        die($e->getMessage());
        Severity: Minor
        Found in src/services/Webhooks.php by phpmd

        ExitExpression

        Since: 0.2

        An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

        Example

        class Foo {
            public function bar($param)  {
                if ($param === 42) {
                    exit(23);
                }
            }
        }

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

        Avoid unused local variables such as '$subscriptionn_id'.
        Open

              throw new Exception(sprintf(__('Pedido da assinatura #%s para o ciclo #%s não encontrado!', VINDI), $subscriptionn_id, $cycle), 2);
        Severity: Minor
        Found in src/services/Webhooks.php by phpmd

        UnusedLocalVariable

        Since: 0.2

        Detects when a local variable is declared and/or assigned, but not used.

        Example

        class Foo {
            public function doSomething()
            {
                $i = 5; // Unused
            }
        }

        Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

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

          private function find_order_by_id($id)
        Severity: Minor
        Found in src/services/Webhooks.php by phpmd

        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

        The property $vindi_settings is not named in camelCase.
        Open

        class VindiWebhooks
        {
          /**
           * @var VindiSettings
           */
        Severity: Minor
        Found in src/services/Webhooks.php by phpmd

        CamelCasePropertyName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name attributes.

        Example

        class ClassName {
            protected $property_name;
        }

        Source

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

          private function find_bill_by_charge_id($id)
        Severity: Minor
        Found in src/services/Webhooks.php by phpmd

        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

        Opening brace indented incorrectly; expected 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Opening brace indented incorrectly; expected 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Opening brace indented incorrectly; expected 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Blank line found at start of control structure
        Open

            if ($vindi_subscription && isset($vindi_subscription['next_billing_at'])) {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Opening brace indented incorrectly; expected 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Inline control structures are not allowed
        Open

            if (null == $body || empty($body->event))
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Inline control structures are not allowed
        Open

            if (false === $query->have_posts())
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line exceeds 120 characters; contains 138 characters
        Open

              throw new Exception(sprintf(__('Pedido da assinatura #%s para o ciclo #%s não encontrado!', VINDI), $subscriptionn_id, $cycle), 2);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Inline control structures are not allowed
        Open

            if (empty($subscription))
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Inline control structures are not allowed
        Open

            if ('open' !== $issue_status)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Inline control structures are not allowed
        Open

            if ('charge' !== $item_type)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Inline control structures are not allowed
        Open

            if (false === $query->have_posts())
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Inline control structures are not allowed
        Open

            if ('charge_underpay' !== $issue_type)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Inline control structures are not allowed
        Open

            if (empty($order))
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Inline control structures are not allowed
        Open

            if (empty($charge))
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 8 spaces, found 4
        Open

            if (method_exists($this, $type)) {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $this->vindi_settings->logger->log(sprintf(__('Evento do webhook ignorado pelo plugin: ', VINDI), $type));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              throw new Exception(__('Falha ao interpretar JSON do webhook: Evento do Webhook não encontrado!', VINDI));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          private function process_event($body)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            if (null == $body || empty($body->event))
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 6
        Open

              return $this->{$type}($data);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          private $vindi_settings;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 6
        Open

              $this->vindi_settings->logger->log(sprintf(__('Novo Evento processado: %s', VINDI), $type));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              $this->routes = $vindi_settings->routes;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            return $token === $this->vindi_settings->get_token();
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $type = $body->event->type;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 8 spaces, found 4
        Open

            }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          private function validate_access_token($token)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $data = $body->event->data;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $this->vindi_settings->logger->log(__('Evento de teste do webhook.', VINDI));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          private $routes;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          private function test($data)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              $this->vindi_settings = $vindi_settings;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            ));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              'post_type' => 'shop_order',
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 12 spaces, found 6
        Open

              if (empty($data->bill->subscription)) {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              $order->id,
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            return wc_get_order($query->post->ID);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 6
        Open

              $subscription->update_dates(array('next_payment' => $next_payment));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 8 spaces, found 4
        Open

            }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Multi-line function call not indented correctly; expected 10 spaces but found 8
        Open

                __('Já existe o ciclo %s para a assinatura #%s pedido #%s!', VINDI),
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $issue_status = $data->issue->status;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            );
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            return wc_get_order($query->post->ID);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              array(
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            return date('Y-m-d H:i:s', strtotime($date));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $order = $this->find_order_by_id($order_id);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $this->vindi_settings->logger->log('Novo Período criado: Pedido #'.$order->id);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 16 spaces, found 8
        Open

                $vindi_subscription_id = $data->bill->subscription->id;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 16 spaces, found 8
        Open

                $cycle = $data->bill->period->cycle;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              throw new Exception(sprintf(__('Pendência criada com o status "%s" não processada!', VINDI), $issue_status));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              throw new Exception(sprintf(__('Pendência criada com o item do tipo "%s" não processada!', VINDI), $item_type));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $item_id = (int) $data->issue->item_id;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $order = $this->find_order_by_bill_id($bill->id);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 8 spaces, found 6
        Open

              }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            if (empty($order))
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              'meta_query' => $metas,
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 8 spaces, found 4
        Open

            if ($vindi_subscription && isset($vindi_subscription['next_billing_at'])) {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 6
        Open

              $subscription = $this->find_subscription_by_id($data->bill->subscription->code);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              __('Divergencia de valores do Pedido #%s: Valor Esperado R$ %s, Valor Pago R$ %s.', VINDI),
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $subscription = wcs_get_subscription(end($sanitized_id));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $args = array(
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              'meta_key' => 'vindi_bill_id',
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $query = $this->query_order_by_metas(array(
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            return $query->have_posts();
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              'post_status' => 'any',
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 8
        Open

                $renew_infos['vindi_subscription_id'],
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 16 spaces, found 8
        Open

                $order = $this->find_order_by_subscription_and_cycle($vindi_subscription_id, $cycle);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $issue_type = $data->issue->issue_type;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              $issue_data->transaction_amount
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $charge = $this->routes->getCharge($id);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              throw new Exception(sprintf(__('Cobrança #%s não encontrada!', VINDI), $id), 2);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              array(
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 6
        Open

              $end_date = $this->format_date($end_at);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 8 spaces, found 4
        Open

            }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $subscription_id = $renew_infos['vindi_subscription_id'];
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $order->add_order_note(sprintf(
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            ));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 8 spaces, found 6
        Open

              try {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            if (empty($subscription))
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              'post_status' => 'any',
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $query = $this->query_order_by_metas(array(
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              ),
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 16 spaces, found 8
        Open

                return false;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          private function format_date($date)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 8
        Open

                __('Já existe o ciclo %s para a assinatura #%s pedido #%s!', VINDI),
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            return $subscription;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            return new WP_Query($args);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $vindi_subscription = $this->routes->getSubscription($data->bill->subscription->id);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $subscription = $this->find_subscription_by_id($renew_infos['wc_subscription_id']);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 8
        Open

                $subscription->get_last_order()
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            remove_action('woocommerce_scheduled_subscription_payment', 'WC_Subscriptions_Manager::prepare_renewal');
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 16 spaces, found 14
        Open

                      $order = $this->find_order_by_id($data->bill->code);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 12 spaces, found 6
        Open

              }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $item_type = strtolower($data->issue->item_type);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            if ('open' !== $issue_status)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Multi-line function call not indented correctly; expected 8 spaces but found 6
        Open

              __('Divergencia de valores do Pedido #%s: Valor Esperado R$ %s, Valor Pago R$ %s.', VINDI),
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              $issue_data->expected_amount,
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $query = new WP_Query($args);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            if (false === $query->have_posts())
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 6
        Open

              $next_billing_at = $vindi_subscription['next_billing_at'];
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 12 spaces, found 6
        Open

              if ($end_at != null && $next_billing_at > $end_at) {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 8 spaces, found 4
        Open

            if ($this->subscription_has_order_in_cycle($renew_infos['vindi_subscription_id'], $renew_infos['cycle'])) {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Multi-line function call not indented correctly; expected 10 spaces but found 8
        Open

                $subscription->get_last_order()
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 6
        Open

              ));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $order_post_meta[$subscription_id]['product'] = $renew_infos['plan_name'];
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 12 spaces, found 6
        Open

              } else {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Multi-line function call not indented correctly; expected 8 spaces but found 6
        Open

              $issue_data->expected_amount,
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            if (empty($charge))
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          private function find_order_by_id($id)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Multi-line function call not indented correctly; expected 10 spaces but found 8
        Open

                $renew_infos['vindi_subscription_id'],
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $order_id = $subscription->get_last_order();
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 8 spaces, found 4
        Open

            try {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 8 spaces, found 4
        Open

            }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $order = wc_get_order($id);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              'post_type' => 'shop_order',
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 8
        Open

                $renew_infos['cicle'],
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          private function bill_canceled($data)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 8 spaces, found 4
        Open

            } catch (Exception $e) {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              throw new Exception(sprintf(__('Pendência criada com o tipo "%s" não processada!', VINDI), $issue_type));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $issue_data = $data->issue->data;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Multi-line function call not indented correctly; expected 8 spaces but found 6
        Open

              $order->id,
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            return (object) $charge['bill'];
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            );
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 6
        Open

              throw new Exception(sprintf(
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Multi-line function call not indented correctly; expected 10 spaces but found 8
        Open

                $renew_infos['cicle'],
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $order_post_meta[$subscription_id]['cycle'] = $renew_infos['cycle'];
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 6
        Open

              $order->update_status('cancelled', __('Pagamento cancelado dentro da Vindi!', VINDI));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          private function issue_created($data)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            return $order;
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              throw new Exception(sprintf(__('Pedido da assinatura #%s para o ciclo #%s não encontrado!', VINDI), $subscriptionn_id, $cycle), 2);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 6
        Open

              $subscription->update_dates(array('end_date' => $end_date));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            WC_Subscriptions_Manager::prepare_renewal($subscription->id);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 4 spaces, found 2
        Open

          {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            if ('charge_underpay' !== $issue_type)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $bill = $this->find_bill_by_charge_id($item_id);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          private function find_bill_by_charge_id($id)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 4 spaces, found 2
        Open

          }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              throw new Exception(sprintf(__('Pedido com bill_id #%s não encontrado!', VINDI), $bill_id), 2);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 6
        Open

              $end_at = $vindi_subscription['end_at'];
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Multi-line function call not indented correctly; expected 8 spaces but found 6
        Open

              $issue_data->transaction_amount
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 8 spaces, found 6
        Open

              } catch (Exception $e) {
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              'meta_value' => $bill_id,
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            if (false === $query->have_posts())
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            $args = array(
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected 12 spaces, found 6
        Open

              }
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 16 spaces, found 8
        Open

                $order = $this->find_order_by_id($data->bill->code);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            if ('charge' !== $item_type)
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              throw new Exception(sprintf(__('Pedido #%s não encontrado!', VINDI), $id), 2);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 6
        Open

              ),
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 8 spaces, found 4
        Open

            ));
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        Line indented incorrectly; expected at least 12 spaces, found 6
        Open

              $next_payment = $this->format_date($next_billing_at);
        Severity: Minor
        Found in src/services/Webhooks.php by phpcodesniffer

        There are no issues that match your filters.

        Category
        Status