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;
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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());
- Read upRead up
- Exclude checks
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;
- Exclude checks
Returning type false|string
but getLastFourDigits()
is declared to return int
Open
return substr($this->CreditCardNumber, -4);
- Exclude checks
Avoid excessively long variable names like $CreditCardCompanyClearer. Keep variable name length under 20. Open
private $CreditCardCompanyClearer; // ClearerID
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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 {
- Exclude checks
The closing brace for the class must go on the next line after the body Open
}
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
$transaction_response = PelecardHttpRequest::pelecardPostRequest(self::PAYMENT_VALIDATE_URI, $this->getTransactionRequestPayload());
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $TransactionId;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $FirstPaymentTotal;
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$this->extractFieldsFromUserData($transaction_result->UserData);
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private function getTransactionRequestPayload() {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return [
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
];
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $Token;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $CardHolderID; // OwnerIdNum
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 6 Open
if (isset($response->{$property_name})) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getFirstPaymentTotal() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $this->CreditCardCompanyClearer;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$reflection = new \ReflectionClass($this);
- Exclude checks
Opening brace should be on a new line Open
private function getTransactionRequestPayload() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $this->DebitApproveNumber;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return substr($this->CreditCardNumber, -4);
- Exclude checks
Opening brace should be on a new line Open
public function getCreditCardExpDate() {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $this->Token;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getClearer() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $user;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $TotalPayments; // NumberOfPayments
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
'terminal' => $this->terminal,
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
const PAYMENT_VALIDATE_URI = 'PaymentGW/GetTransaction';
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 6 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getCardHolderID() {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $this->CardHolderID;
- Exclude checks
Opening brace should be on a new line Open
public function getClearer() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $DebitTotal; // Amount
- Exclude checks
Opening brace should be on a new line Open
public function __construct($terminal, $user, $password, $TransactionId) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if (!empty($transaction_result->UserData)) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
}
- Exclude checks
Opening brace should be on a new line Open
private function extractPropertiesFromResponse($response) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private function extractFieldsFromUserData($userData) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
1 => 'Isracard',
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $VoucherId; // VoucherNumber
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$this->terminal = $terminal;
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
if (!empty($transaction_result->ResultData)) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
foreach($userData as $fieldName => $data) {
- Exclude checks
Expected 1 space after FOREACH keyword; 0 found Open
foreach($userData as $fieldName => $data) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $this->TotalPayments;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $this->FixedPaymentTotal;
- Exclude checks
Opening brace should be on a new line Open
public function getClearerName() {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$map = [
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
2 => 'Visa Cal',
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $CreditCardNumber;
- Exclude checks
Line indented incorrectly; expected at least 16 spaces, found 8 Open
$this->{$property_name} = $response->{$property_name};
- Exclude checks
Opening brace should be on a new line Open
public function getToken() {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
3 => 'Diners',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$this->TransactionId = $TransactionId;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private function extractPropertiesFromResponse($response) {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $this->CreditCardExpDate;
- Exclude checks
Opening brace should be on a new line Open
public function getFirstPaymentTotal() {
- Exclude checks
Opening brace should be on a new line Open
public function getFixedPaymentTotal() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $terminal;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $CreditCardCompanyClearer; // ClearerID
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $FixedPaymentTotal;
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$this->extractPropertiesFromResponse($transaction_result->ResultData);
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$property_name = $property->getName();
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Opening brace should be on a new line Open
public function getLastFourDigits() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getToken() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $DebitApproveNumber; // Reference
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$transaction_response = PelecardHttpRequest::pelecardPostRequest(self::PAYMENT_VALIDATE_URI, $this->getTransactionRequestPayload());
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getTransactionTotal() {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $this->DebitTotal;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Opening brace should be on a new line Open
public function getCardHolderID() {
- Exclude checks
Opening brace should be on a new line Open
private function getClearerNamebyNum($num) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function __construct($terminal, $user, $password, $TransactionId) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
foreach ($reflection->getProperties() as $property) {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
'password' => $this->password,
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getCreditCardExpDate() {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $this->FirstPaymentTotal;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$this->password = $password;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$transaction_result = json_decode($transaction_response);
- Exclude checks
Opening brace should be on a new line Open
private function extractFieldsFromUserData($userData) {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
'TransactionId' => $this->TransactionId
- Exclude checks
Opening brace should be on a new line Open
public function getTransactionTotal() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getNumberOfPayments() {
- Exclude checks
Opening brace should be on a new line Open
public function getNumberOfPayments() {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $this->VoucherId;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getAuthorizationNumber() {
- Exclude checks
Opening brace should be on a new line Open
public function getAuthorizationNumber() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getClearerName() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private function getClearerNamebyNum($num) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $password;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$this->UserData = [];
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
'user' => $this->user,
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getVoucherNumber() {
- Exclude checks
Opening brace should be on a new line Open
public function getVoucherNumber() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getLastFourDigits() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $this->getClearerNamebyNum($this->CreditCardCompanyClearer);
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $CreditCardExpDate; // ExpDate
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
private $UserData; // UserData
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
$this->user = $user;
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
$this->UserData[$fieldName] = $data;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getFixedPaymentTotal() {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
4 => 'American Express',
- Exclude checks
Opening brace should be on a new line Open
public function getUserData() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
public function getUserData() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $map[$num];
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 6 Open
6 => 'Leumi card',
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
return $this->UserData;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
];
- Exclude checks
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();
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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();
}
}