dofinity/pelecard

View on GitHub
src/Pelecard/PelecardTransaction.php

Summary

Maintainability
A
0 mins
Test Coverage

The class PelecardTransaction has 16 fields. Consider redesigning PelecardTransaction to keep the number of fields under 15.
Open

class PelecardTransaction {
  const PAYMENT_VALIDATE_URI = 'PaymentGW/GetTransaction';

  private $terminal;
  private $user;
Severity: Minor
Found in src/Pelecard/PelecardTransaction.php by phpmd

TooManyFields

Since: 0.1

Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

Example

class Person {
   protected $one;
   private $two;
   private $three;
   [... many more fields ...]
}

Source https://phpmd.org/rules/codesize.html#toomanyfields

Missing class import via use statement (line '64', column '23').
Open

    $reflection = new \ReflectionClass($this);
Severity: Minor
Found in src/Pelecard/PelecardTransaction.php by phpmd

MissingImport

Since: 2.7.0

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

Example

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

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

Avoid using static access to class 'Pelecard\PelecardHttpRequest' in method '__construct'.
Open

    $transaction_response = PelecardHttpRequest::pelecardPostRequest(self::PAYMENT_VALIDATE_URI, $this->getTransactionRequestPayload());
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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

Possibly zero references to use statement for classlike/namespace Client (\GuzzleHttp\Client)
Open

use GuzzleHttp\Client;
Severity: Minor
Found in src/Pelecard/PelecardTransaction.php by phan

Returning type false|string but getLastFourDigits() is declared to return int
Open

    return substr($this->CreditCardNumber, -4);
Severity: Minor
Found in src/Pelecard/PelecardTransaction.php by phan

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

  private $CreditCardCompanyClearer; // ClearerID
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 parameter $TransactionId is not named in camelCase.
Open

  public function __construct($terminal, $user, $password, $TransactionId) {
    $this->terminal = $terminal;
    $this->user = $user;
    $this->password = $password;
    $this->TransactionId = $TransactionId;
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 PelecardTransaction {

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

}

Line exceeds 120 characters; contains 136 characters
Open

    $transaction_response = PelecardHttpRequest::pelecardPostRequest(self::PAYMENT_VALIDATE_URI, $this->getTransactionRequestPayload());

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $TransactionId;

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $FirstPaymentTotal;

Line indented incorrectly; expected 8 spaces, found 4
Open

    }

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

      $this->extractFieldsFromUserData($transaction_result->UserData);

Line indented incorrectly; expected 8 spaces, found 4
Open

    }

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

Line indented incorrectly; expected 4 spaces, found 2
Open

  private function getTransactionRequestPayload() {

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

    return [

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

    ];

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $Token;

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $CardHolderID; // OwnerIdNum

Line indented incorrectly; expected 8 spaces, found 4
Open

    }

Line indented incorrectly; expected 12 spaces, found 6
Open

      if (isset($response->{$property_name})) {

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getFirstPaymentTotal() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

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

    return $this->CreditCardCompanyClearer;

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

    $reflection = new \ReflectionClass($this);

Opening brace should be on a new line
Open

  private function getTransactionRequestPayload() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

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

    return $this->DebitApproveNumber;

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

    return substr($this->CreditCardNumber, -4);

Opening brace should be on a new line
Open

  public function getCreditCardExpDate() {

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

    return $this->Token;

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getClearer() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $user;

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $TotalPayments; // NumberOfPayments

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

      'terminal' => $this->terminal,

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

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

  const PAYMENT_VALIDATE_URI = 'PaymentGW/GetTransaction';

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

Line indented incorrectly; expected 12 spaces, found 6
Open

      }

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getCardHolderID() {

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

    return $this->CardHolderID;

Opening brace should be on a new line
Open

  public function getClearer() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $DebitTotal; // Amount

Opening brace should be on a new line
Open

  public function __construct($terminal, $user, $password, $TransactionId) {

Line indented incorrectly; expected 8 spaces, found 4
Open

    if (!empty($transaction_result->UserData)) {

Line indented incorrectly; expected 8 spaces, found 4
Open

    }

Opening brace should be on a new line
Open

  private function extractPropertiesFromResponse($response) {

Line indented incorrectly; expected 4 spaces, found 2
Open

  private function extractFieldsFromUserData($userData) {

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

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

      1 => 'Isracard',

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $VoucherId; // VoucherNumber

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

    $this->terminal = $terminal;

Line indented incorrectly; expected 8 spaces, found 4
Open

    if (!empty($transaction_result->ResultData)) {

Line indented incorrectly; expected 8 spaces, found 4
Open

    foreach($userData as $fieldName => $data) {

Expected 1 space after FOREACH keyword; 0 found
Open

    foreach($userData as $fieldName => $data) {

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

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

    return $this->TotalPayments;

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

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

    return $this->FixedPaymentTotal;

Opening brace should be on a new line
Open

  public function getClearerName() {

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

    $map = [

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

      2 => 'Visa Cal',

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $CreditCardNumber;

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

        $this->{$property_name} = $response->{$property_name};

Opening brace should be on a new line
Open

  public function getToken() {

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

      3 => 'Diners',

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

    $this->TransactionId = $TransactionId;

Line indented incorrectly; expected 4 spaces, found 2
Open

  private function extractPropertiesFromResponse($response) {

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

    return $this->CreditCardExpDate;

Opening brace should be on a new line
Open

  public function getFirstPaymentTotal() {

Opening brace should be on a new line
Open

  public function getFixedPaymentTotal() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $terminal;

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $CreditCardCompanyClearer; // ClearerID

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $FixedPaymentTotal;

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

      $this->extractPropertiesFromResponse($transaction_result->ResultData);

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

      $property_name = $property->getName();

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

Opening brace should be on a new line
Open

  public function getLastFourDigits() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getToken() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $DebitApproveNumber; // Reference

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

    $transaction_response = PelecardHttpRequest::pelecardPostRequest(self::PAYMENT_VALIDATE_URI, $this->getTransactionRequestPayload());

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getTransactionTotal() {

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

    return $this->DebitTotal;

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

Opening brace should be on a new line
Open

  public function getCardHolderID() {

Opening brace should be on a new line
Open

  private function getClearerNamebyNum($num) {

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function __construct($terminal, $user, $password, $TransactionId) {

Line indented incorrectly; expected 8 spaces, found 4
Open

    foreach ($reflection->getProperties() as $property) {

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

      'password' => $this->password,

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getCreditCardExpDate() {

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

    return $this->FirstPaymentTotal;

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

    $this->password = $password;

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

    $transaction_result = json_decode($transaction_response);

Opening brace should be on a new line
Open

  private function extractFieldsFromUserData($userData) {

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

      'TransactionId' => $this->TransactionId

Opening brace should be on a new line
Open

  public function getTransactionTotal() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getNumberOfPayments() {

Opening brace should be on a new line
Open

  public function getNumberOfPayments() {

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

    return $this->VoucherId;

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getAuthorizationNumber() {

Opening brace should be on a new line
Open

  public function getAuthorizationNumber() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getClearerName() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  private function getClearerNamebyNum($num) {

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $password;

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

    $this->UserData = [];

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

      'user' => $this->user,

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getVoucherNumber() {

Opening brace should be on a new line
Open

  public function getVoucherNumber() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getLastFourDigits() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

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

    return $this->getClearerNamebyNum($this->CreditCardCompanyClearer);

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $CreditCardExpDate; // ExpDate

Line indented incorrectly; expected 4 spaces, found 2
Open

  private $UserData; // UserData

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

    $this->user = $user;

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

      $this->UserData[$fieldName] = $data;

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getFixedPaymentTotal() {

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

      4 => 'American Express',

Opening brace should be on a new line
Open

  public function getUserData() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  public function getUserData() {

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

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

    return $map[$num];

Line indented incorrectly; expected 4 spaces, found 2
Open

  }

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

      6 => 'Leumi card',

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

    return $this->UserData;

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

    ];

The variable $property_name is not named in camelCase.
Open

  private function extractPropertiesFromResponse($response) {
    $reflection = new \ReflectionClass($this);

    foreach ($reflection->getProperties() as $property) {
      $property_name = $property->getName();
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 $property_name is not named in camelCase.
Open

  private function extractPropertiesFromResponse($response) {
    $reflection = new \ReflectionClass($this);

    foreach ($reflection->getProperties() as $property) {
      $property_name = $property->getName();
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 $transaction_response is not named in camelCase.
Open

  public function __construct($terminal, $user, $password, $TransactionId) {
    $this->terminal = $terminal;
    $this->user = $user;
    $this->password = $password;
    $this->TransactionId = $TransactionId;
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 $transaction_result is not named in camelCase.
Open

  public function __construct($terminal, $user, $password, $TransactionId) {
    $this->terminal = $terminal;
    $this->user = $user;
    $this->password = $password;
    $this->TransactionId = $TransactionId;
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 $transaction_result is not named in camelCase.
Open

  public function __construct($terminal, $user, $password, $TransactionId) {
    $this->terminal = $terminal;
    $this->user = $user;
    $this->password = $password;
    $this->TransactionId = $TransactionId;
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 $property_name is not named in camelCase.
Open

  private function extractPropertiesFromResponse($response) {
    $reflection = new \ReflectionClass($this);

    foreach ($reflection->getProperties() as $property) {
      $property_name = $property->getName();
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 $transaction_result is not named in camelCase.
Open

  public function __construct($terminal, $user, $password, $TransactionId) {
    $this->terminal = $terminal;
    $this->user = $user;
    $this->password = $password;
    $this->TransactionId = $TransactionId;
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 $transaction_result is not named in camelCase.
Open

  public function __construct($terminal, $user, $password, $TransactionId) {
    $this->terminal = $terminal;
    $this->user = $user;
    $this->password = $password;
    $this->TransactionId = $TransactionId;
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 $transaction_result is not named in camelCase.
Open

  public function __construct($terminal, $user, $password, $TransactionId) {
    $this->terminal = $terminal;
    $this->user = $user;
    $this->password = $password;
    $this->TransactionId = $TransactionId;
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 $transaction_response is not named in camelCase.
Open

  public function __construct($terminal, $user, $password, $TransactionId) {
    $this->terminal = $terminal;
    $this->user = $user;
    $this->password = $password;
    $this->TransactionId = $TransactionId;
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 $property_name is not named in camelCase.
Open

  private function extractPropertiesFromResponse($response) {
    $reflection = new \ReflectionClass($this);

    foreach ($reflection->getProperties() as $property) {
      $property_name = $property->getName();
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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 $TransactionId is not named in camelCase.
Open

  public function __construct($terminal, $user, $password, $TransactionId) {
    $this->terminal = $terminal;
    $this->user = $user;
    $this->password = $password;
    $this->TransactionId = $TransactionId;
Severity: Minor
Found in src/Pelecard/PelecardTransaction.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