Function updatePaymentStatus
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function updatePaymentStatus(int $recordId)
{
$changes = false;
$recordModel = \Vtiger_Record_Model::getInstanceById($recordId, static::$moduleName);
if (!empty(static::$fieldPaymentStatusName)) {
- 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
Function updateIfPossible
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function updateIfPossible(Vtiger_Record_Model $recordModel)
{
if (static::canUpdatePaymentStatus($recordModel)) {
if ($currentRelatedId = $recordModel->get(static::$relatedRecordIdName)) {
(new \App\BatchMethod(['method' => static::class . '::updatePaymentStatus', 'params' => [$currentRelatedId]]))->save();
- 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
Missing class import via use statement (line '60', column '10'). Open
(new \App\BatchMethod(['method' => static::class . '::updatePaymentStatus', 'params' => [$previousRelatedId]]))->save();
- 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
Missing class import via use statement (line '56', column '10'). Open
(new \App\BatchMethod(['method' => static::class . '::updatePaymentStatus', 'params' => [$currentRelatedId]]))->save();
- 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 '\App\Cache' in method 'getSumOfPaymentsByRecordId'. Open
\App\Cache::staticSave($cacheNamespace, $recordId, $sumOfPayments);
- 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
The method calculatePaymentStatus uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$paymentStatus = 'PLL_OVERPAID';
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Validator' in method 'calculatePaymentStatus'. Open
if (\App\Validator::floatIsEqual($sumOfGross, $sumOfPayments, 3)) {
- 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
The method getSumOfPaymentsByRecordId uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$relationModel = Vtiger_Relation_Model::getInstance(
Vtiger_Module_Model::getInstance($moduleName),
Vtiger_Module_Model::getInstance('PaymentsIn')
);
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'Vtiger_Relation_Model' in method 'getSumOfPaymentsByRecordId'. Open
$relationModel = Vtiger_Relation_Model::getInstance(
Vtiger_Module_Model::getInstance($moduleName),
Vtiger_Module_Model::getInstance('PaymentsIn')
);
- 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
Avoid using static access to class '\App\Cache' in method 'getSumOfPaymentsByRecordId'. Open
if (\App\Cache::staticHas($cacheNamespace, $recordId)) {
- 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
Avoid using static access to class 'Vtiger_Module_Model' in method 'getSumOfPaymentsByRecordId'. Open
Vtiger_Module_Model::getInstance($moduleName),
- 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
Avoid using static access to class '\Vtiger_Record_Model' in method 'updatePaymentStatus'. Open
$recordModel = \Vtiger_Record_Model::getInstanceById($recordId, static::$moduleName);
- 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
Avoid using static access to class 'Vtiger_Module_Model' in method 'getSumOfPaymentsByRecordId'. Open
Vtiger_Module_Model::getInstance('PaymentsIn')
- 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
Avoid using static access to class '\App\Validator' in method 'calculatePaymentStatus'. Open
} elseif (\App\Validator::floatIsEqual(0.0, $sumOfPayments, 3)) {
- 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
Avoid assigning values to variables in if clauses and the like (line '55', column '8'). Open
public static function updateIfPossible(Vtiger_Record_Model $recordModel)
{
if (static::canUpdatePaymentStatus($recordModel)) {
if ($currentRelatedId = $recordModel->get(static::$relatedRecordIdName)) {
(new \App\BatchMethod(['method' => static::class . '::updatePaymentStatus', 'params' => [$currentRelatedId]]))->save();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class 'Vtiger_Record_Model' in method 'getSumOfPaymentsByRecordId'. Open
$relationModel->set('parentRecord', Vtiger_Record_Model::getInstanceById($recordId, $moduleName));
- 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
Avoid using static access to class '\App\Cache' in method 'getSumOfPaymentsByRecordId'. Open
$sumOfPayments = (float) \App\Cache::staticGet($cacheNamespace, $recordId);
- 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
Call to method addNativeCondition
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->addNativeCondition(['vtiger_paymentsin.paymentsin_status' => 'PLL_PAID']);
- Exclude checks
Call to method floatIsEqual
from undeclared class \App\Validator
(Did you mean class \Tests\App\Validator) Open
if (\App\Validator::floatIsEqual($sumOfGross, $sumOfPayments, 3)) {
- Exclude checks
Call to method createQuery
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$sumOfPayments = (float) $queryGenerator->createQuery()
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::staticSave()
takes string
defined at /code/app/Cache.php:156
Open
\App\Cache::staticSave($cacheNamespace, $recordId, $sumOfPayments);
- Exclude checks
Call to method floatIsEqual
from undeclared class \App\Validator
(Did you mean class \Tests\App\Validator) Open
} elseif (\App\Validator::floatIsEqual(0.0, $sumOfPayments, 3)) {
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::staticHas()
takes string
defined at /code/app/Cache.php:141
Open
if (\App\Cache::staticHas($cacheNamespace, $recordId)) {
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::staticGet()
takes string
defined at /code/app/Cache.php:128
Open
$sumOfPayments = (float) \App\Cache::staticGet($cacheNamespace, $recordId);
- Exclude checks
Avoid excessively long variable names like $fieldPaymentStatusName. Keep variable name length under 20. Open
protected static $fieldPaymentStatusName;
- 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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
abstract class PaymentsIn_PaymentStatus_Model
- Exclude checks
The class PaymentsIn_PaymentStatus_Model is not named in CamelCase. Open
abstract class PaymentsIn_PaymentStatus_Model
{
/**
* Module name.
*
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
* Module name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($statusFieldModel && $statusFieldModel->isActiveField()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::$fieldPaymentStatusName,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$changes = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cacheNamespace = "getSumOfPaymentsByRecordId.{$moduleName}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Vtiger_Module_Model::getInstance($moduleName),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $sumOfPayments;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected static function calculatePaymentStatus(float $sumOfGross, float $sumOfPayments): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
(new \App\BatchMethod(['method' => static::class . '::updatePaymentStatus', 'params' => [$currentRelatedId]]))->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $recordId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sumOfPayments = (float) \App\Cache::staticGet($cacheNamespace, $recordId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator = $relationModel->getQuery();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($sumOfGross > $sumOfPayments) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$paymentStatus = 'PLL_OVERPAID';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (static::canUpdatePaymentStatus($recordModel)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationModel = Vtiger_Relation_Model::getInstance(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $recordId
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
static::calculatePaymentStatus((float) $recordModel->get('sum_gross'), static::getSumOfPaymentsByRecordId($recordId, static::$moduleName))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Vtiger_Module_Model::getInstance('PaymentsIn')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $paymentStatus;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected static $fieldPaymentStatusName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function updateIfPossible(Vtiger_Record_Model $recordModel)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sumFieldModel = $recordModel->getField(static::$fieldPaymentSumName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return float
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$changes = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty(static::$fieldPaymentSumName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($changes) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationModel->set('parentRecord', Vtiger_Record_Model::getInstanceById($recordId, $moduleName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->addNativeCondition(['vtiger_paymentsin.paymentsin_status' => 'PLL_PAID']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sumOfPayments = (float) $queryGenerator->createQuery()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Validator::floatIsEqual($sumOfGross, $sumOfPayments, 3)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$paymentStatus = 'PLL_PAID';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($returnValue) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected static $moduleName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($currentRelatedId = $recordModel->get(static::$relatedRecordIdName)) {
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
(new \App\BatchMethod(['method' => static::class . '::updatePaymentStatus', 'params' => [$previousRelatedId]]))->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function updatePaymentStatus(int $recordId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check if payment fields for update changed.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Related record ID name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Update if possible.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new \App\BatchMethod(['method' => static::class . '::updatePaymentStatus', 'params' => [$previousRelatedId]]))->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::staticSave($cacheNamespace, $recordId, $sumOfPayments);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$paymentStatus = 'PLL_NOT_PAID';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$paymentStatus = 'PLL_UNDERPAID';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected static $relatedRecordIdName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Calculate payment status.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param float $sumOfPayments
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected static function canUpdatePaymentStatus(Vtiger_Record_Model $recordModel): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = \Vtiger_Record_Model::getInstanceById($recordId, static::$moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$statusFieldModel = $recordModel->getField(static::$fieldPaymentStatusName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($sumFieldModel && $sumFieldModel->isActiveField()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::getSumOfPaymentsByRecordId($recordId, static::$moduleName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== $recordModel->getPreviousValue($fieldName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$changes = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Line exceeds 120 characters; contains 168 characters Open
$returnValue = !$recordModel->isEmpty(static::$relatedRecordIdName) && ($recordModel->isNew() || false !== $recordModel->getPreviousValue('paymentsin_status'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected static $fieldPaymentSumName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== $previousRelatedId && $previousRelatedId > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty(static::$fieldPaymentStatusName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSumOfPaymentsByRecordId(int $recordId, string $moduleName): float
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Checking if you can update the payment status.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$returnValue = !$recordModel->isEmpty(static::$relatedRecordIdName) && ($recordModel->isNew() || false !== $recordModel->getPreviousValue('paymentsin_status'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->sum('vtiger_paymentsin.paymentsvalue');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Field payment status name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$previousRelatedId = $recordModel->getPreviousValue(static::$relatedRecordIdName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get the sum of all payments by record ID.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$returnValue = $fieldModel && $fieldModel->isActiveField();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fieldsToCheck as $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Field payment sum name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Update payment status.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (\App\Validator::floatIsEqual(0.0, $sumOfPayments, 3)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = \Vtiger_Module_Model::getInstance(static::$moduleName)->getFieldByName(static::$fieldPaymentStatusName);
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
$fieldModel = \Vtiger_Module_Model::getInstance(static::$moduleName)->getFieldByName(static::$fieldPaymentStatusName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected static function checkIfPaymentFieldsChanged(Vtiger_Record_Model $recordModel): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new \App\BatchMethod(['method' => static::class . '::updatePaymentStatus', 'params' => [$currentRelatedId]]))->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::calculatePaymentStatus((float) $recordModel->get('sum_gross'), static::getSumOfPaymentsByRecordId($recordId, static::$moduleName))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::$fieldPaymentSumName,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Cache::staticHas($cacheNamespace, $recordId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param float $sumOfGross
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $returnValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsToCheck = ['paymentsin_status', 'finvoiceid', 'ssingleordersid', 'finvoiceproformaid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $result;
- Exclude checks
Class name "PaymentsIn_PaymentStatus_Model" is not in camel caps format Open
abstract class PaymentsIn_PaymentStatus_Model
- Exclude checks