src/Pelecard/PelecardPaymentStatus.php
File PelecardPaymentStatus.php
has 783 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
/**
* @file PelecardPaymentStatus class - allows to get payment status message based on status code
*/
namespace Pelecard;
Function getMessage
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
public function getMessage() {
if (!is_string($this->code) || !array_key_exists($this->code, PelecardPaymentStatus::MESSAGES)) {
// invalid status code provided, should be string value
return null;
}
- Read upRead up
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 getMessage
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getMessage() {
if (!is_string($this->code) || !array_key_exists($this->code, PelecardPaymentStatus::MESSAGES)) {
// invalid status code provided, should be string value
return null;
}
The method getMessage() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
Open
public function getMessage() {
if (!is_string($this->code) || !array_key_exists($this->code, PelecardPaymentStatus::MESSAGES)) {
// invalid status code provided, should be string value
return null;
}
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Opening brace of a class must be on the line after the definition Open
Open
class PelecardPaymentStatus {
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
Open
break;
- Exclude checks
The closing brace for the class must go on the next line after the body Open
Open
}
- Exclude checks
Line exceeds 120 characters; contains 149 characters Open
Open
'HE' => 'הפרש בימים בקליטת חסומים גדול מדי - בצע שידור או בקשה לאישור עבור כל עסקה.',
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
Open
'EN' => 'The difference in generations in the blocked cards input is too large, transmit or request authorization for each transaction.',
- Exclude checks
Line exceeds 120 characters; contains 139 characters Open
Open
'HE' => 'לא הוכנס פס מגנטי כולו. הגדר עסקה כעסקה טלפונית או כעסקת חתימה בלבד.',
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
Open
'HE' => 'למסוף אין אישור לעסקת כוכבים/נקודות/מיילים לסוג אשראי זה.',
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
Open
'HE' => 'כרטיס לא רשאי לבצע עסקת אשראי גמיש (עדיף +30/) עפ"י הגדרת המערכת. (VECTOR21 של דיינרס).',
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
Open
'EN' => 'The card belongs to a group that is not permitted to execute transactions according to system definitions (Visa VECTOR 20).',
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
Open
'EN' => 'The transaction`s amount exceeds the ceiling when the input file contains J1, J2 or J3 (contact prohibited).',
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
Open
'EN' => 'Defective card according to system definitions (Isracard VECTOR1), error in the number of figures on the card.',
- Exclude checks
Line exceeds 120 characters; contains 144 characters Open
Open
'EN' => 'The card is not permitted to execute flexible credit transactions (Adif/30+) according to system definitions (Diners VECTOR21).',
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
Open
'HE' => 'לא ניתן לבטל עסקה קודמת (עסקת זכות או מספר כרטיס אינו זהה).',
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
Open
'HE' => 'קיים תשלום ראשון ו/או תשלום קבוע לסוג אשראי שונה מתשלומים.',
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
Open
'EN' => 'The card is not permitted to execute dollar transactions according to system definitions (Isracard VECTOR1).',
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
Open
'HE' => 'תוכנית הופסקה עפ"י הוראת המפעיל (ESC) או COM PORT לא ניתן לפתיחה (Windows).',
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
Open
'HE' => 'מספר מסוף מרכזי לא הוכנס לשאילתה במסוף המוגדר לעבודה כרב ספק.',
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
Open
'HE' => 'מספר תשלומים גדול מידי על פי רשימת כרטיסים תקפים של ישראכרט.',
- Exclude checks
Line exceeds 120 characters; contains 146 characters Open
Open
'HE' => 'כרטיס לא רשאי לבצע עסקאות חיוב מיידי עפ"י הגדרת המערכת. (VECTOR21 של דיינרס).',
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
Open
'HE' => 'כרטיס לא רשאי לבצע עסקאות בתשלומים על פי רשימת כרטיסים תקפים של ישראכרט.',
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
Open
'HE' => 'קידומת הכרטיס (7 ספרות) לא תקפה עפ”י הגדרת המערכת (VECTOR21 של דיינרס).',
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
Open
'HE' => 'כרטיס לא רשאי לבצע עסקאות דולריות עפ”י הגדרת המערכת (VECTOR1 של ישראכרט).',
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
Open
'HE' => 'כרטיס לא רשאי לבצע עסקאות בתשלומים עפ"י וקטור 31 של לאומיקארד.',
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
Open
'HE' => 'תקלת תקשורת, יש לנסות שוב או לפנות למנהל המערכת ולמסור את קוד התשובה',
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
Open
'HE' => 'מסוף חייב לבקש אישור כאשר רשומת הקלט מכילה J3 או J2 או J1 (אסור להתקשר).',
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
Open
'HE' => 'כרטיס אינו רשאי לבצע עסקאות טלפוניות עפ"י וקטור 31 של לאומיקארד.',
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
Open
'HE' => 'מסוף שאינו מעודכן כרב ספק/רב מוטב והוקלד מספר ספק/מספר מוטב.',
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
Open
'HE' => 'מסוף לא מוגדר כתחנת דלק. (הועבר כרטיס דלק או קוד עסקה לא מתאים).',
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
Open
'HE' => 'כרטיס לא תקין עפ”י הגדרת המערכת (VECTOR1 של ישראכרט)- מספר הספרות בכרטיס- שגוי.',
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
Open
'HE' => 'כרטיס אמריקן אקספרס אשר הונפק בחוייל לא רשאי לבצע עסקאות בתשלומים.',
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
Open
'HE' => 'קובץ חסומים (NEG) לא קיים או לא מעודכן - בצע שידור או בקשה לאישור עבור כל עסקה.',
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
Open
'HE' => 'כרטיסי ויזה ודיינרס לא רשאים לבצע עסקאות מועדון בתשלומים.',
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
Open
'EN' => 'The card is not permitted to carry out installment transactions according to Isracard`s list of valid cards.',
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
Open
'EN' => 'The card is not permitted for telephone and signature-only transactions according to Alpha vector no. 31.',
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
Open
'EN' => 'The supplier/beneficiary number was entered, however the terminal was not updated as the main supplier/beneficiary.',
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
Open
'HE' => 'בתחנות דלק לא ניתן לבצע "שרות עצמי" אלא "שרות עצמי בתחנות דלק".',
- Exclude checks
Line exceeds 120 characters; contains 156 characters Open
Open
'EN' => 'Installment error, the amount of transactions needs to be equal to: first installment plus fixed installments times number of installments.',
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
Open
'EN' => 'Blocked cards file (NEG) does not exist or has not been updated, transmit or request authorization for each transaction.',
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
Open
'EN' => 'The difference in days in the blocked cards input is too large, transmit or request authorization for each transaction.',
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
Open
'HE' => 'כרטיס חסום בספק כאשר רשומת הקלט מכילה J3 או J2 או J1 (אסור להתקשר).',
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
Open
'HE' => 'הפרש דורות בקליטת חסומים גדול מידי - בצע שידור או בקשה לאישור עבור כל עסקה.',
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
Open
'EN' => 'The terminal must request authorization where the input file contains J1, J2 or J3 (contact prohibited).',
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
Open
'EN' => 'The card is not permitted to execute immediate debit transactions according to system definitions (Diners VECTOR21).',
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
Open
'EN' => 'When the magnetic strip is not completely entered, define the transaction as a telephone number or signature only.',
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
Open
'HE' => 'מסוף מבצע שידור ו/או מעדכן נתונים. אנא נסה שנית מאוחר יותר.',
- Exclude checks
Line exceeds 120 characters; contains 172 characters Open
Open
'HE' => 'שגיאה בתשלומים - סכום עסקה צריך להיות שווה תשלום ראשון +(תשלום קבוע כפול מספר תשלומים).',
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
Open
'HE' => 'חייב להקליד מספר סודי, כאשר רשומת הקלט מכילה J3 או J2 או J1 (אסור להתקשר).',
- Exclude checks
Line exceeds 120 characters; contains 175 characters Open
Open
'HE' => 'הכרטיס שייך לקבוצת כרטיסים אשר אינה רשאית לבצע עסקאות עפ”י הגדרת המערכת (VECTOR20 של ויזה).',
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
Open
'HE' => 'סידרת כרטיסים לא תקפה עפ”י הגדרת המערכת. (VECTOR5 של ישראכרט).',
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
Open
'HE' => 'קידומת הכרטיס (2 ספרות) לא תקפה עפ”י הגדרת המערכת. (VECTOR7 של ישראכרט).',
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
Open
'HE' => 'כרטיס לא רשאי לבצע עסקאות טלפוניות וחתימה בלבד עפ"י ווקטור 31 של לאומיקארד.',
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 6 Open
Open
case 'HE':
- Exclude checks
Line indented incorrectly; expected at least 16 spaces, found 8 Open
Open
$outputMessage = null;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
protected $locale = 'HE';
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->locale = $locale;
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
return $this->code;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
protected $code;
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
Open
}
- Exclude checks
Expected 1 newline at end of file; 0 found Open
Open
}
- Exclude checks
Opening brace should be on a new line Open
Open
public function __construct($statusCode, $locale = 'HE') {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
}
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
Open
$outputLocale = strtoupper($this->locale);
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 6 Open
Open
case 'EN':
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
public function getCode() {
- Exclude checks
Line indented incorrectly; expected at least 12 spaces, found 6 Open
Open
return null;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
public function __toString() {
- Exclude checks
Opening brace should be on a new line Open
Open
public function __toString() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 8 Open
Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$messageHe = PelecardPaymentStatus::MESSAGES[$this->code]['HE'];
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
return (is_string($this->getMessage())) ? $this->getMessage() : '';
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
Open
const MESSAGES = [
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 8 Open
Open
}
- Exclude checks
Opening brace should be on a new line Open
Open
public function getCode() {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
public function getMessage() {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
Open
if (is_string($this->locale) && in_array(strtoupper($this->locale), ['HE', 'EN'], true)) {
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
Open
];
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
Open
public function __construct($statusCode, $locale = 'HE') {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
Open
if (!is_string($this->code) || !array_key_exists($this->code, PelecardPaymentStatus::MESSAGES)) {
- Exclude checks
Line indented incorrectly; expected at least 20 spaces, found 10 Open
Open
$outputMessage = $messageEn;
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 6 Open
Open
default:
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$this->code = $statusCode;
- Exclude checks
Line indented incorrectly; expected at least 20 spaces, found 10 Open
Open
$outputMessage = $messageEn;
- Exclude checks
Opening brace should be on a new line Open
Open
public function getMessage() {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$outputLocale = 'HE';
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
Open
switch ($outputLocale) {
- Exclude checks
Line indented incorrectly; expected at least 20 spaces, found 10 Open
Open
$outputMessage = $messageHe;
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 8 Open
Open
} elseif (!empty($messageEn)) {
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$outputMessage = null;
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 8 Open
Open
if (!empty($messageEn)) {
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 8 Open
Open
if (!empty($messageHe)) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
$messageEn = PelecardPaymentStatus::MESSAGES[$this->code]['EN'];
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
Open
return $outputMessage;
- Exclude checks