YetiForceCompany/YetiForceCRM

View on GitHub
modules/PaymentsIn/models/PaymentStatus.php

Summary

Maintainability
A
1 hr
Test Coverage
B
85%

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)) {
Severity: Minor
Found in modules/PaymentsIn/models/PaymentStatus.php - About 45 mins to fix

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();
Severity: Minor
Found in modules/PaymentsIn/models/PaymentStatus.php - About 25 mins to fix

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();

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();

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);

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';
        }

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)) {

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')
            );

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')
            );

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)) {

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),

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);

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')

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)) {

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();

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));

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);

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']);

Call to method floatIsEqual from undeclared class \App\Validator (Did you mean class \Tests\App\Validator)
Open

        if (\App\Validator::floatIsEqual($sumOfGross, $sumOfPayments, 3)) {

Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

            $sumOfPayments = (float) $queryGenerator->createQuery()

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);

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)) {

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)) {

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);

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

    protected static $fieldPaymentStatusName;

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

The class PaymentsIn_PaymentStatus_Model is not named in CamelCase.
Open

abstract class PaymentsIn_PaymentStatus_Model
{
    /**
     * Module name.
     *

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.

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

            if ($statusFieldModel && $statusFieldModel->isActiveField()) {

Spaces must be used to indent lines; tabs are not allowed
Open

                    static::$fieldPaymentStatusName,

Spaces must be used to indent lines; tabs are not allowed
Open

                $changes = true;

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

        $cacheNamespace = "getSumOfPaymentsByRecordId.{$moduleName}";

Spaces must be used to indent lines; tabs are not allowed
Open

                Vtiger_Module_Model::getInstance($moduleName),

Spaces must be used to indent lines; tabs are not allowed
Open

        return $sumOfPayments;

Spaces must be used to indent lines; tabs are not allowed
Open

    protected static function calculatePaymentStatus(float $sumOfGross, float $sumOfPayments): string

Spaces must be used to indent lines; tabs are not allowed
Open

        } else {

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Line exceeds 120 characters; contains 135 characters
Open

                (new \App\BatchMethod(['method' => static::class . '::updatePaymentStatus', 'params' => [$currentRelatedId]]))->save();

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int    $recordId

Spaces must be used to indent lines; tabs are not allowed
Open

            $sumOfPayments = (float) \App\Cache::staticGet($cacheNamespace, $recordId);

Spaces must be used to indent lines; tabs are not allowed
Open

        } else {

Spaces must be used to indent lines; tabs are not allowed
Open

            $queryGenerator = $relationModel->getQuery();

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        } elseif ($sumOfGross > $sumOfPayments) {

Spaces must be used to indent lines; tabs are not allowed
Open

            $paymentStatus = 'PLL_OVERPAID';

Spaces must be used to indent lines; tabs are not allowed
Open

        if (static::canUpdatePaymentStatus($recordModel)) {

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

            $relationModel = Vtiger_Relation_Model::getInstance(

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param Vtiger_Record_Model $recordModel

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var string

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int $recordId

Line exceeds 120 characters; contains 158 characters
Open

                    static::calculatePaymentStatus((float) $recordModel->get('sum_gross'), static::getSumOfPaymentsByRecordId($recordId, static::$moduleName))

Spaces must be used to indent lines; tabs are not allowed
Open

                Vtiger_Module_Model::getInstance('PaymentsIn')

Spaces must be used to indent lines; tabs are not allowed
Open

        return $paymentStatus;

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    protected static $fieldPaymentStatusName;

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function updateIfPossible(Vtiger_Record_Model $recordModel)

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

            $sumFieldModel = $recordModel->getField(static::$fieldPaymentSumName);

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return float

Spaces must be used to indent lines; tabs are not allowed
Open

        $changes = false;

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!empty(static::$fieldPaymentSumName)) {

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($changes) {

Spaces must be used to indent lines; tabs are not allowed
Open

            $recordModel->save();

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $moduleName

Spaces must be used to indent lines; tabs are not allowed
Open

            $relationModel->set('parentRecord', Vtiger_Record_Model::getInstanceById($recordId, $moduleName));

Spaces must be used to indent lines; tabs are not allowed
Open

            $queryGenerator->addNativeCondition(['vtiger_paymentsin.paymentsin_status' => 'PLL_PAID']);

Spaces must be used to indent lines; tabs are not allowed
Open

            $sumOfPayments = (float) $queryGenerator->createQuery()

Spaces must be used to indent lines; tabs are not allowed
Open

        if (\App\Validator::floatIsEqual($sumOfGross, $sumOfPayments, 3)) {

Spaces must be used to indent lines; tabs are not allowed
Open

            $paymentStatus = 'PLL_PAID';

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($returnValue) {

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    protected static $moduleName;

Spaces must be used to indent lines; tabs are not allowed
Open

            if ($currentRelatedId = $recordModel->get(static::$relatedRecordIdName)) {

Line exceeds 120 characters; contains 136 characters
Open

                (new \App\BatchMethod(['method' => static::class . '::updatePaymentStatus', 'params' => [$previousRelatedId]]))->save();

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function updatePaymentStatus(int $recordId)

Spaces must be used to indent lines; tabs are not allowed
Open

                $recordModel->set(

Spaces must be used to indent lines; tabs are not allowed
Open

                );

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     * Check if payment fields for update changed.

Spaces must be used to indent lines; tabs are not allowed
Open

     * Related record ID name.

Spaces must be used to indent lines; tabs are not allowed
Open

     * Update if possible.

Spaces must be used to indent lines; tabs are not allowed
Open

                (new \App\BatchMethod(['method' => static::class . '::updatePaymentStatus', 'params' => [$previousRelatedId]]))->save();

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            );

Spaces must be used to indent lines; tabs are not allowed
Open

            \App\Cache::staticSave($cacheNamespace, $recordId, $sumOfPayments);

Spaces must be used to indent lines; tabs are not allowed
Open

            $paymentStatus = 'PLL_NOT_PAID';

Spaces must be used to indent lines; tabs are not allowed
Open

            $paymentStatus = 'PLL_UNDERPAID';

Spaces must be used to indent lines; tabs are not allowed
Open

                break;

Spaces must be used to indent lines; tabs are not allowed
Open

    protected static $relatedRecordIdName;

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param Vtiger_Record_Model $recordModel

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Calculate payment status.

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param float $sumOfPayments

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    protected static function canUpdatePaymentStatus(Vtiger_Record_Model $recordModel): bool

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        $recordModel = \Vtiger_Record_Model::getInstanceById($recordId, static::$moduleName);

Spaces must be used to indent lines; tabs are not allowed
Open

            $statusFieldModel = $recordModel->getField(static::$fieldPaymentStatusName);

Spaces must be used to indent lines; tabs are not allowed
Open

            if ($sumFieldModel && $sumFieldModel->isActiveField()) {

Spaces must be used to indent lines; tabs are not allowed
Open

                    static::getSumOfPaymentsByRecordId($recordId, static::$moduleName)

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

            if (false !== $recordModel->getPreviousValue($fieldName)) {

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return void

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

                $changes = true;

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Line exceeds 120 characters; contains 168 characters
Open

        $returnValue = !$recordModel->isEmpty(static::$relatedRecordIdName) && ($recordModel->isNew() || false !== $recordModel->getPreviousValue('paymentsin_status'));

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        $result = false;

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    protected static $fieldPaymentSumName;

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            if (false !== $previousRelatedId && $previousRelatedId > 0) {

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!empty(static::$fieldPaymentStatusName)) {

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function getSumOfPaymentsByRecordId(int $recordId, string $moduleName): float

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * Checking if you can update the payment status.

Spaces must be used to indent lines; tabs are not allowed
Open

        $returnValue = !$recordModel->isEmpty(static::$relatedRecordIdName) && ($recordModel->isNew() || false !== $recordModel->getPreviousValue('paymentsin_status'));

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var string

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

                $recordModel->set(

Spaces must be used to indent lines; tabs are not allowed
Open

                );

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

                ->sum('vtiger_paymentsin.paymentsvalue');

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * Field payment status name.

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            $previousRelatedId = $recordModel->getPreviousValue(static::$relatedRecordIdName);

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get the sum of all payments by record ID.

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

            $returnValue = $fieldModel && $fieldModel->isActiveField();

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($fieldsToCheck as $fieldName) {

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var string

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * Field payment sum name.

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var string

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return void

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Update payment status.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        } elseif (\App\Validator::floatIsEqual(0.0, $sumOfPayments, 3)) {

Spaces must be used to indent lines; tabs are not allowed
Open

            $fieldModel = \Vtiger_Module_Model::getInstance(static::$moduleName)->getFieldByName(static::$fieldPaymentStatusName);

Line exceeds 120 characters; contains 130 characters
Open

            $fieldModel = \Vtiger_Module_Model::getInstance(static::$moduleName)->getFieldByName(static::$fieldPaymentStatusName);

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    protected static function checkIfPaymentFieldsChanged(Vtiger_Record_Model $recordModel): bool

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

                (new \App\BatchMethod(['method' => static::class . '::updatePaymentStatus', 'params' => [$currentRelatedId]]))->save();

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

                    static::calculatePaymentStatus((float) $recordModel->get('sum_gross'), static::getSumOfPaymentsByRecordId($recordId, static::$moduleName))

Spaces must be used to indent lines; tabs are not allowed
Open

                    static::$fieldPaymentSumName,

Spaces must be used to indent lines; tabs are not allowed
Open

        if (\App\Cache::staticHas($cacheNamespace, $recordId)) {

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param float $sumOfGross

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        return $returnValue;

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param Vtiger_Record_Model $recordModel

Spaces must be used to indent lines; tabs are not allowed
Open

                $result = true;

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

        $fieldsToCheck = ['paymentsin_status', 'finvoiceid', 'ssingleordersid', 'finvoiceproformaid'];

Spaces must be used to indent lines; tabs are not allowed
Open

        return $result;

Class name "PaymentsIn_PaymentStatus_Model" is not in camel caps format
Open

abstract class PaymentsIn_PaymentStatus_Model

There are no issues that match your filters.

Category
Status