dofinity/pelecard

View on GitHub
src/Pelecard/PaymentResponse.php

Summary

Maintainability
A
1 hr
Test Coverage

Method __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

  public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
Severity: Major
Found in src/Pelecard/PaymentResponse.php - About 1 hr to fix

    This function has 8 parameters, which is greater than the 7 authorized.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
    Severity: Major
    Found in src/Pelecard/PaymentResponse.php by sonar-php

    A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

    Noncompliant Code Example

    With a maximum number of 4 parameters:

    function doSomething($param1, $param2, $param3, $param4, $param5) {
    ...
    }
    

    Compliant Solution

    function doSomething($param1, $param2, $param3, $param4) {
    ...
    }
    

    Saw an @param annotation for UniqueKey, but it was not found in the param list of function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, mixed|string $ApprovalNo = '', mixed|string $Token = '')
    Open

       * @param $UniqueKey
    Severity: Info
    Found in src/Pelecard/PaymentResponse.php by phan

    Expected @param annotation for TotalX100 to be before the @param annotation for ApprovalNo
    Open

       * @param $ApprovalNo
    Severity: Info
    Found in src/Pelecard/PaymentResponse.php by phan

    Avoid excessively long variable names like $PelecardTransactionId. Keep variable name length under 20.
    Open

      protected $PelecardTransactionId;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

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

    Avoid excessively long variable names like $PelecardTransactionId. Keep variable name length under 20.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

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

    Avoid excessively long variable names like $USER_INPUT_ERROR_CODES. Keep variable name length under 20.
    Open

      public static $USER_INPUT_ERROR_CODES = ['006', '033', '036'];
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

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

    The property $USER_INPUT_ERROR_CODES is not named in camelCase.
    Open

    class PaymentResponse implements \JsonSerializable {
    
      protected $PelecardStatusCode;
      protected $PelecardTransactionId;
      protected $ApprovalNo;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.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

    The parameter $Token is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $ConfirmationKey is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $ParamX is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $PelecardTransactionId is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $TotalX100 is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $PelecardStatusCode is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $UserKey is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $ApprovalNo is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    Opening brace of a class must be on the line after the definition
    Open

    class PaymentResponse implements \JsonSerializable {

    The closing brace for the class must go on the next line after the body
    Open

    }

    Line exceeds 120 characters; contains 156 characters
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {

    Line exceeds 120 characters; contains 151 characters
    Open

          'UniqueKey' => !empty($this->UserKey) ? $this->UserKey : $this->PelecardTransactionId, // Send the UserKey if given, otherwise the transaction ID

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

        $this->UserKey = $UserKey;

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

        $this->PelecardStatusCode = $PelecardStatusCode;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      protected $TotalX100;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

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

        $this->ParamX = $ParamX;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function getPelecardStatusCode() {

    Opening brace should be on a new line
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {

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

        return $this->PelecardTransactionId;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      protected $PelecardStatusCode;

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

        $this->PelecardTransactionId = $PelecardTransactionId;

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

        $this->ApprovalNo = $ApprovalNo;

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

      const TIMEOUT_ERROR_CODE = '301';

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

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

        $this->ConfirmationKey = $ConfirmationKey;

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

          'ConfirmationKey' => $this->ConfirmationKey,

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

          'UniqueKey' => !empty($this->UserKey) ? $this->UserKey : $this->PelecardTransactionId, // Send the UserKey if given, otherwise the transaction ID

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      protected $PelecardTransactionId;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public static $USER_INPUT_ERROR_CODES = ['006', '033', '036'];

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

        $this->TotalX100 = $TotalX100;

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

        return $this->PelecardStatusCode;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      protected $Token;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function getPelecardTransactionId() {

    Opening brace should be on a new line
    Open

      public function getPelecardTransactionId() {

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

        return [

    Opening brace should be on a new line
    Open

      public function getValidationRequestStruct() {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      protected $ConfirmationKey;

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

        $this->Token = $Token;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      protected $ParamX;

    Opening brace should be on a new line
    Open

      public function getPelecardStatusCode() {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function getValidationRequestStruct() {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      protected $UserKey;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      protected $ApprovalNo;

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function isStatusSuccess() {

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

        return get_object_vars($this);

    Opening brace should be on a new line
    Open

      public static function isTimeoutErrorCode($errorCode) {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function isTimeoutError() {

    Opening brace should be on a new line
    Open

      public function isRetriesAllowed() {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public static function isUserInputErrorByCode($errorCode) {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

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

          'TotalX100' => $this->TotalX100

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

        ];

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

        return ($errorCode == self::TIMEOUT_ERROR_CODE);

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function isRetriesAllowed() {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public static function isTimeoutErrorCode($errorCode) {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

    Opening brace should be on a new line
    Open

      public function isStatusSuccess() {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      public function jsonSerialize() {

    Opening brace should be on a new line
    Open

      public function jsonSerialize() {

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

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

        return static::isTimeoutErrorCode($this->PelecardStatusCode);

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      private function isUserInputError() {

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

        return static::isUserInputErrorByCode($this->PelecardStatusCode);

    Opening brace should be on a new line
    Open

      private function isUserInputError() {

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

        return in_array($errorCode, self::$USER_INPUT_ERROR_CODES);

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

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

        return ($this->PelecardStatusCode != '000' && !$this->isUserInputError() && !$this->isTimeoutError());

    Opening brace should be on a new line
    Open

      public static function isUserInputErrorByCode($errorCode) {

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

        return ($this->PelecardStatusCode == '000');

    Line indented incorrectly; expected 4 spaces, found 2
    Open

      }

    Opening brace should be on a new line
    Open

      public function isTimeoutError() {

    The variable $PelecardStatusCode is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $PelecardTransactionId is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $Token is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $ApprovalNo is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $UserKey is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $ParamX is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $ConfirmationKey is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $TotalX100 is not named in camelCase.
    Open

      public function __construct($PelecardStatusCode, $PelecardTransactionId, $ParamX, $UserKey, $ConfirmationKey, $TotalX100, $ApprovalNo = '', $Token = '') {
        $this->PelecardStatusCode = $PelecardStatusCode;
        $this->PelecardTransactionId = $PelecardTransactionId;
        $this->ApprovalNo = $ApprovalNo;
        $this->Token = $Token;
    Severity: Minor
    Found in src/Pelecard/PaymentResponse.php by phpmd

    CamelCaseVariableName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status