paypay/paypayopa-sdk-php

View on GitHub

Showing 15 of 15 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function revertAuth($payload)
    {
        $this->payloadTypeCheck($payload, new RevertAuthPayload());
        $main = $this->MainInst;
        $data = $payload->serialize();
Severity: Major
Found in src/Controllers/Payment.php and 1 other location - About 3 hrs to fix
src/Controllers/Payment.php on lines 178..189

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 160.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function capturePaymentAuth($payload)
    {
        $this->payloadTypeCheck($payload, new CapturePaymentAuthPayload());
        $main = $this->MainInst;
        $data = $payload->serialize();
Severity: Major
Found in src/Controllers/Payment.php and 1 other location - About 3 hrs to fix
src/Controllers/Payment.php on lines 202..213

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 160.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function validate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate($throwErrors = true)
    {
        $faults = [];
        $iterable = get_object_vars($this);
        foreach ($this->descriptor as $memberName => $memberInfo) {
Severity: Minor
Found in src/core/Model.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 doCall has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function doCall($lookupApi, $apiId, $url, $data, $options)
    {
        if ($lookupApi) {
            $apiInfo = $this->main()->GetApiMapping($apiId);
            $callType = strtolower($apiInfo["method"]);
Severity: Minor
Found in src/core/Controller.php - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function getRefundDetails($merchantRefundId)
        {
            $main = $this->MainInst;
            $url = $main->GetConfig('API_URL') . $main->GetEndpoint('REFUND') . "/$merchantRefundId";
            $endpoint = '/v2' . $main->GetEndpoint('REFUND') . "/$merchantRefundId";
    Severity: Major
    Found in src/Controllers/Refund.php and 1 other location - About 1 hr to fix
    src/Controllers/CashBack.php on lines 61..68

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 105.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function getCashbackDetails($merchatCashbackId, $paymentType = 'CASHBACK')
        {
            $main = $this->MainInst;
            $url = $main->GetConfig('API_URL') . $main->GetEndpoint('CASHBACK') . "/$merchatCashbackId";
            $endpoint = '/v2' . $main->GetEndpoint('CASHBACK') . "/$merchatCashbackId";
    Severity: Major
    Found in src/Controllers/CashBack.php and 1 other location - About 1 hr to fix
    src/Controllers/Refund.php on lines 51..59

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 105.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function doCall has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function doCall($lookupApi, $apiId, $url, $data, $options)
        {
            if ($lookupApi) {
                $apiInfo = $this->main()->GetApiMapping($apiId);
                $callType = strtolower($apiInfo["method"]);
    Severity: Minor
    Found in src/core/Controller.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 __construct has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct($auth = null, $productionmode = false, $requestHandler = false)
        {
            if (!isset($auth['API_KEY']) || !isset($auth['API_SECRET'])) {
                throw new ClientException("Invalid auth credentials", 1);
            }
    Severity: Minor
    Found in src/Client.php - About 1 hr to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public function getMaskedUserProfile($userAuthorizationId)
          {
              if (!$userAuthorizationId) {
                  $userAuthorizationId = $this->userAuthorizationId;
              }
      Severity: Minor
      Found in src/Controllers/User.php and 1 other location - About 1 hr to fix
      src/Controllers/User.php on lines 91..101

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 100.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public function getUserAuthorizationStatus($userAuthorizationId)
          {
              if (!$userAuthorizationId) {
                  $userAuthorizationId = $this->userAuthorizationId;
              }
      Severity: Minor
      Found in src/Controllers/User.php and 1 other location - About 1 hr to fix
      src/Controllers/User.php on lines 111..121

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 100.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Method PayPayEncryptHeader has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function PayPayEncryptHeader($apiKey, $apiSecret, $method, $resource, $contentType, $payload)
      Severity: Minor
      Found in src/helpers/utility_hmac.php - About 45 mins to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            public function getPaymentDetails($merchantPaymentId, $paymentType = 'web_cashier')
            {
                $endpoint = $this->endpointByPaymentType($paymentType, $merchantPaymentId)['endpoint'];
                $url = $this->endpointByPaymentType($paymentType, $merchantPaymentId)['url'];
                $options = $this->HmacCallOpts('GET', $endpoint);
        Severity: Minor
        Found in src/Controllers/Payment.php and 1 other location - About 45 mins to fix
        src/Controllers/Payment.php on lines 134..140

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 95.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            public function cancelPayment($merchantPaymentId, $paymentType = 'web_cashier')
            {
                $endpoint = $this->endpointByPaymentType($paymentType, $merchantPaymentId)['endpoint'];
                $url = $this->endpointByPaymentType($paymentType, $merchantPaymentId)['url'];
                $options = $this->HmacCallOpts('DELETE', $endpoint);
        Severity: Minor
        Found in src/Controllers/Payment.php and 1 other location - About 45 mins to fix
        src/Controllers/Payment.php on lines 114..120

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 95.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

            protected function doCall($lookupApi, $apiId, $url, $data, $options)
        Severity: Minor
        Found in src/core/Controller.php - About 35 mins to fix

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

              public function __construct($auth = null, $productionmode = false, $requestHandler = false)
              {
                  if (!isset($auth['API_KEY']) || !isset($auth['API_SECRET'])) {
                      throw new ClientException("Invalid auth credentials", 1);
                  }
          Severity: Minor
          Found in src/Client.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

          Severity
          Category
          Status
          Source
          Language