Function checkCondition
has a Cognitive Complexity of 110 (exceeds 5 allowed). Consider refactoring. Open
public function checkCondition(Vtiger_Record_Model $recordModel, $cond, Vtiger_Record_Model $referredRecordModel = null)
{
$condition = $cond['operation'];
$fieldInstance = $recordModel->getModule()->getFieldByName($cond['fieldname']);
if (empty($condition) || false === $fieldInstance) {
- 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 checkCondition
has 377 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function checkCondition(Vtiger_Record_Model $recordModel, $cond, Vtiger_Record_Model $referredRecordModel = null)
{
$condition = $cond['operation'];
$fieldInstance = $recordModel->getModule()->getFieldByName($cond['fieldname']);
if (empty($condition) || false === $fieldInstance) {
Function evaluate
has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring. Open
public function evaluate($condition, Vtiger_Record_Model $recordModel)
{
$expr = \App\Json::decode($condition);
$finalResult = true;
if (\is_array($expr)) {
- 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
File VTJsonCondition.php
has 494 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/* +**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
Method evaluate
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function evaluate($condition, Vtiger_Record_Model $recordModel)
{
$expr = \App\Json::decode($condition);
$finalResult = true;
if (\is_array($expr)) {
The class VTJsonCondition has an overall complexity of 192 which is very high. The configured complexity threshold is 50. Open
class VTJsonCondition
{
/**
* Evaluate.
*
- Exclude checks
Avoid too many return
statements within this method. Open
return $result;
Avoid too many return
statements within this method. Open
return 'on' === $fieldValue || 1 === $fieldValue || '1' === $fieldValue;
Avoid too many return
statements within this method. Open
return preg_match($value, $fieldValue);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return empty(array_diff($value, $fieldValue));
Avoid too many return
statements within this method. Open
return !\in_array($fieldValue, $value);
Avoid too many return
statements within this method. Open
return $fieldValue != $hasChanged;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $recordModel->get($fieldInstance->getName()) !== $recordModel->get('created_user_id');
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $fieldValue > $value;
Avoid too many return
statements within this method. Open
return $fieldValue != $value;
Avoid too many return
statements within this method. Open
return $fieldValue != $value;
Avoid too many return
statements within this method. Open
return \in_array($fieldValue, $value);
Avoid too many return
statements within this method. Open
return $fieldValue < $value;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return !empty(array_diff($value, $fieldValue));
Avoid too many return
statements within this method. Open
return $this->startsWith($fieldValue, $value);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $result;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return ($recordModel->isNew() || false !== $oldValue) && $recordModel->get($cond['fieldname']) == $value;
Avoid too many return
statements within this method. Open
return $fieldValue == $value;
Avoid too many return
statements within this method. Open
return 'off' === $fieldValue || 0 === $fieldValue || '0' === $fieldValue || '' === $fieldValue;
Avoid too many return
statements within this method. Open
return false === $recordModel->getPreviousValue($cond['fieldname']);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return (int) $value !== \App\User::getCurrentUserId() ? false : true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return 'on' === $fieldValue || 1 === $fieldValue || '1' === $fieldValue;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return (int) $value === \App\User::getCurrentUserId() ? false : true;
Avoid too many return
statements within this method. Open
return $fieldValue > $value;
Avoid too many return
statements within this method. Open
return $fieldValue <= $value;
Avoid too many return
statements within this method. Open
return $fieldValue >= $value;
Avoid too many return
statements within this method. Open
return 'off' === $fieldValue || 0 === $fieldValue || '0' === $fieldValue || '' === $fieldValue;
Avoid too many return
statements within this method. Open
return $fieldValue == $value;
Avoid too many return
statements within this method. Open
return false === strpos($fieldValue, $value);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return $fieldValue < $value;
Avoid too many return
statements within this method. Open
return $this->endsWith($fieldValue, $value);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false !== strpos($fieldValue, $value);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
The method checkCondition() has 398 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function checkCondition(Vtiger_Record_Model $recordModel, $cond, Vtiger_Record_Model $referredRecordModel = null)
{
$condition = $cond['operation'];
$fieldInstance = $recordModel->getModule()->getFieldByName($cond['fieldname']);
if (empty($condition) || false === $fieldInstance) {
- Exclude checks
The method checkCondition() has an NPath complexity of 453000. The configured NPath complexity threshold is 200. Open
public function checkCondition(Vtiger_Record_Model $recordModel, $cond, Vtiger_Record_Model $referredRecordModel = null)
{
$condition = $cond['operation'];
$fieldInstance = $recordModel->getModule()->getFieldByName($cond['fieldname']);
if (empty($condition) || false === $fieldInstance) {
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method evaluate() has an NPath complexity of 7525. The configured NPath complexity threshold is 200. Open
public function evaluate($condition, Vtiger_Record_Model $recordModel)
{
$expr = \App\Json::decode($condition);
$finalResult = true;
if (\is_array($expr)) {
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method checkCondition() has a Cyclomatic Complexity of 159. The configured cyclomatic complexity threshold is 10. Open
public function checkCondition(Vtiger_Record_Model $recordModel, $cond, Vtiger_Record_Model $referredRecordModel = null)
{
$condition = $cond['operation'];
$fieldInstance = $recordModel->getModule()->getFieldByName($cond['fieldname']);
if (empty($condition) || false === $fieldInstance) {
- 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
The method evaluate() has a Cyclomatic Complexity of 29. The configured cyclomatic complexity threshold is 10. Open
public function evaluate($condition, Vtiger_Record_Model $recordModel)
{
$expr = \App\Json::decode($condition);
$finalResult = true;
if (\is_array($expr)) {
- 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
This function "checkCondition" has 397 lines, which is greater than the 150 lines authorized. Split it into smaller functions. Open
public function checkCondition(Vtiger_Record_Model $recordModel, $cond, Vtiger_Record_Model $referredRecordModel = null)
- Read upRead up
- Exclude checks
A function that grows too large tends to aggregate too many responsibilities.
Such functions inevitably become harder to understand and therefore harder to maintain.
Above a specific threshold, it is strongly advised to refactor into smaller functions which focus on well-defined tasks.
Those smaller functions will not only be easier to understand, but also probably easier to test.
Reduce the number of switch cases from 42 to at most 30. Open
switch ($condition) {
- Read upRead up
- Exclude checks
When switch
statements have large sets of case
clauses, it is usually an attempt to map two sets of data. A real map
structure would be more readable and maintainable, and should be used instead.
Refactor this function to reduce its Cognitive Complexity from 81 to the 15 allowed. Open
public function evaluate($condition, Vtiger_Record_Model $recordModel)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Reduce the number of returns of this function 89, down to the maximum allowed 3. Open
public function checkCondition(Vtiger_Record_Model $recordModel, $cond, Vtiger_Record_Model $referredRecordModel = null)
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
Refactor this function to reduce its Cognitive Complexity from 187 to the 15 allowed. Open
public function checkCondition(Vtiger_Record_Model $recordModel, $cond, Vtiger_Record_Model $referredRecordModel = null)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
The class VTJsonCondition has a coupling between objects value of 17. Consider to reduce the number of dependencies under 13. Open
class VTJsonCondition
{
/**
* Evaluate.
*
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '176', column '18'). Open
$parser = new VTExpressionParser(new VTExpressionSpaceFilter(new VTExpressionTokenizer($value)));
- 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 '176', column '69'). Open
$parser = new VTExpressionParser(new VTExpressionSpaceFilter(new VTExpressionTokenizer($value)));
- 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 '176', column '41'). Open
$parser = new VTExpressionParser(new VTExpressionSpaceFilter(new VTExpressionTokenizer($value)));
- 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 '178', column '25'). Open
$exprEvaluater = new VTFieldExpressionEvaluater($expression);
- 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 '541', column '15'). Open
throw new \App\Exceptions\AppException('Found an unexpected condition: ' . $condition);
- 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 assigning values to variables in if clauses and the like (line '531', column '7'). Open
public function checkCondition(Vtiger_Record_Model $recordModel, $cond, Vtiger_Record_Model $referredRecordModel = null)
{
$condition = $cond['operation'];
$fieldInstance = $recordModel->getModule()->getFieldByName($cond['fieldname']);
if (empty($condition) || false === $fieldInstance) {
- 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
The method checkCondition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldValue = $recordModel->get($fieldName);
}
- 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\Json' in method 'evaluate'. Open
$expr = \App\Json::decode($condition);
- 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 checkCondition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$value = $recordModel->get($value);
}
- 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_Watchdog_Model' in method 'checkCondition'. Open
$watchdog = Vtiger_Watchdog_Model::getInstanceById($recordModel->getId(), $recordModel->getModuleName());
- 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\User' in method 'checkCondition'. Open
return (int) $value !== \App\User::getCurrentUserId() ? false : true;
- 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 evaluate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else { // Case for the first condition
$groupResult = $result;
}
- 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 assigning values to variables in if clauses and the like (line '523', column '7'). Open
public function checkCondition(Vtiger_Record_Model $recordModel, $cond, Vtiger_Record_Model $referredRecordModel = null)
{
$condition = $cond['operation'];
$fieldInstance = $recordModel->getModule()->getFieldByName($cond['fieldname']);
if (empty($condition) || false === $fieldInstance) {
- 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 '\Settings_TreesManager_Record_Model' in method 'checkCondition'. Open
$value = \Settings_TreesManager_Record_Model::getChildren(implode('##', $value), $fieldInstance->getColumnName(), \Vtiger_Module_Model::getInstance($recordModel->getModule()->getName()));
- 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 checkCondition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$fieldValue = $recordModel->get($cond['fieldname']);
}
- 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 '\Settings_TreesManager_Record_Model' in method 'checkCondition'. Open
$value = \Settings_TreesManager_Record_Model::getChildren(implode('##', $value), $fieldInstance->getColumnName(), \Vtiger_Module_Model::getInstance($recordModel->getModule()->getName()));
- 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_Watchdog_Model' in method 'checkCondition'. Open
$watchdog = Vtiger_Watchdog_Model::getInstanceById($recordModel->getId(), $recordModel->getModuleName());
- 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\Record' in method 'evaluate'. Open
if (\App\Record::isExists($referenceFieldId)) {
- 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 evaluate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else { // Case for the first condition
$finalResult = $result;
}
- 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\User' in method 'checkCondition'. Open
return (int) $value === \App\User::getCurrentUserId() ? false : true;
- 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\RecordStatus' in method 'checkCondition'. Open
($fieldName = App\RecordStatus::getFieldName($recordModel->getModule()->getName()))
- 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\RecordStatus' in method 'checkCondition'. Open
&& \in_array($recordModel->get($fieldName), App\RecordStatus::getStates($recordModel->getModule()->getName(), \App\RecordStatus::RECORD_STATE_CLOSED))
- 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\Fields\Owner' in method 'evaluate'. Open
} elseif ('Users' === \App\Fields\Owner::getType($referenceFieldId) && \App\User::getUserModel($referenceFieldId)->isActive()) {
- 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\Fields\Date' in method 'checkCondition'. Open
$value = \App\Fields\Date::formatToDb($value, true);
- 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 'evaluate'. Open
$referenceRecordModel = Vtiger_Record_Model::getInstanceById($referenceFieldId);
- 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 checkCondition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$value = [];
}
- 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
The method evaluate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$referenceField = $matches[1];
$referenceModule = $matches[2];
$fieldname = $matches[3];
$result = false;
- 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\RecordStatus' in method 'checkCondition'. Open
($fieldName = App\RecordStatus::getFieldName($recordModel->getModule()->getName()))
- 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 checkCondition uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$value = $exprEvaluater->evaluate($recordModel);
}
- 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_Record_Model' in method 'evaluate'. Open
$referenceRecordModel = Vtiger_Record_Model::getInstanceById($referenceFieldId, $referenceModule);
- 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 'checkCondition'. Open
$value = \Settings_TreesManager_Record_Model::getChildren(implode('##', $value), $fieldInstance->getColumnName(), \Vtiger_Module_Model::getInstance($recordModel->getModule()->getName()));
- 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 'checkCondition'. Open
$value = \Settings_TreesManager_Record_Model::getChildren(implode('##', $value), $fieldInstance->getColumnName(), \Vtiger_Module_Model::getInstance($recordModel->getModule()->getName()));
- 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\RecordStatus' in method 'checkCondition'. Open
&& \in_array($recordModel->get($fieldName), App\RecordStatus::getStates($recordModel->getModule()->getName(), \App\RecordStatus::RECORD_STATE_OPEN))
- 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
Define a constant instead of duplicating this literal "is not" 5 times. Open
if (\in_array($condition, ['contains', 'contains hierarchy', 'does not contain', 'does not contain hierarchy', 'is', 'is not'])) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal " hours" 4 times. Open
$olderDateTime = date('Y-m-d H:i:s', strtotime('-' . $value . ' hours'));
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "contains" 5 times. Open
if (\in_array($condition, ['contains', 'contains hierarchy', 'does not contain', 'does not contain hierarchy', 'is', 'is not'])) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "result" 6 times. Open
$expressionResults[$conditionGroup][$i]['result'] = $this->checkCondition($recordModel, $cond);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Y-m-d H:i:s" 8 times. Open
$value = date('Y-m-d H:i:s');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "does not contain" 5 times. Open
if (\in_array($condition, ['contains', 'contains hierarchy', 'does not contain', 'does not contain hierarchy', 'is', 'is not'])) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal " days" 6 times. Open
$olderDate = date('Y-m-d', strtotime('-' . $value . ' days'));
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "logicaloperator" 5 times. Open
$expressionResults[$conditionGroup][$i + 1]['logicaloperator'] = (!empty($cond['joincondition'])) ? $cond['joincondition'] : 'and';
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "datetime" 4 times. Open
if ('datetime' === $dataType || 'date' === $dataType) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Y-m-d" 11 times. Open
$value = date('Y-m-d');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "fieldname" 10 times. Open
preg_match('/(\w+) : \((\w+)\) (\w+)/', $cond['fieldname'], $matches);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Argument 1 (moduleName)
is false
but \App\RecordStatus::getFieldName()
takes string
defined at /code/app/RecordStatus.php:406
Open
($fieldName = App\RecordStatus::getFieldName($recordModel->getModule()->getName()))
- Exclude checks
Argument 1 (moduleName)
is false
but \App\RecordStatus::getFieldName()
takes string
defined at /code/app/RecordStatus.php:406
Open
($fieldName = App\RecordStatus::getFieldName($recordModel->getModule()->getName()))
- Exclude checks
Argument 1 (mixed)
is false
but \Vtiger_Module_Model::getInstance()
takes int|string
defined at /code/modules/Vtiger/models/Module.php:197
Open
$value = \Settings_TreesManager_Record_Model::getChildren(implode('##', $value), $fieldInstance->getColumnName(), \Vtiger_Module_Model::getInstance($recordModel->getModule()->getName()));
- Exclude checks
Argument 1 (encodedValue)
is array
but \App\Json::decode()
takes string
defined at /code/app/Json.php:37
Open
$expr = \App\Json::decode($condition);
- Exclude checks
Argument 1 (mixed)
is false
but \Vtiger_Module_Model::getInstance()
takes int|string
defined at /code/modules/Vtiger/models/Module.php:197
Open
$value = \Settings_TreesManager_Record_Model::getChildren(implode('##', $value), $fieldInstance->getColumnName(), \Vtiger_Module_Model::getInstance($recordModel->getModule()->getName()));
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
return (int) $value === \App\User::getCurrentUserId() ? false : true;
- Exclude checks
Returning type bool
but evaluate()
is declared to return string
Open
return $finalResult;
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
return (int) $value !== \App\User::getCurrentUserId() ? false : true;
- Exclude checks
Argument 1 (moduleName)
is false
but \App\RecordStatus::getStates()
takes string
defined at /code/app/RecordStatus.php:113
Open
&& \in_array($recordModel->get($fieldName), App\RecordStatus::getStates($recordModel->getModule()->getName(), \App\RecordStatus::RECORD_STATE_CLOSED))
- Exclude checks
Call to method getType
from undeclared class \App\Fields\Owner
Open
} elseif ('Users' === \App\Fields\Owner::getType($referenceFieldId) && \App\User::getUserModel($referenceFieldId)->isActive()) {
- Exclude checks
Argument 1 (moduleName)
is false
but \App\RecordStatus::getStates()
takes string
defined at /code/app/RecordStatus.php:113
Open
&& \in_array($recordModel->get($fieldName), App\RecordStatus::getStates($recordModel->getModule()->getName(), \App\RecordStatus::RECORD_STATE_OPEN))
- Exclude checks
Call to method getUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
} elseif ('Users' === \App\Fields\Owner::getType($referenceFieldId) && \App\User::getUserModel($referenceFieldId)->isActive()) {
- Exclude checks
Argument 1 (array_arg)
is string
but \sort()
takes array
Open
sort($value);
- Exclude checks
Remove the code after this "return". Open
return $value === $fieldValue;
- Read upRead up
- Exclude checks
Jump statements (return
, break
, continue
, and goto
) and throw
expressions move
control flow out of the current code block. Typically, any statements in a block that come after a jump or throw
are simply wasted
keystrokes lying in wait to confuse the unwary.
Rarely, as illustrated below, code after a jump or throw
is reachable. However, such code is difficult to understand, and should be
refactored.
Noncompliant Code Example
function fun($a) { $i = 10; return $i + $a; $i++; // this is never executed } function foo($a) { if ($a == 5) { goto error; } else { // do the job } return; error: printf("don't use 5"); // this is reachable but unreadable }
Compliant Solution
function fun($a) { $i = 10; return $i + $a; } function foo($a) { if ($a == 5) { handleError(); } else { // do the job } return; }
See
- MISRA C:2004, 14.1 - There shall be no unreachable code
- MISRA C++:2008, 0-1-1 - A project shall not contain unreachable code
- MISRA C++:2008, 0-1-9 - There shall be no dead code
- MISRA C:2012, 2.1 - A project shall not contain unreachable code
- MISRA C:2012, 2.2 - There shall be no dead code
- MITRE, CWE-561 - Dead Code
- CERT, MSC56-J. - Detect and remove superfluous code and values
- CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
- CERT, MSC07-CPP. - Detect and remove dead code
Similar blocks of code found in 3 locations. Consider refactoring. Open
case 'less than hours later':
if (empty($rawFieldValue) || empty($value)) {
return false;
}
$currentTime = date('Y-m-d H:i:s');
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 98.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
case 'less than hours before':
if (empty($rawFieldValue) || empty($value)) {
return false;
}
$currentTime = date('Y-m-d H:i:s');
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 98.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
case 'in less than':
if (empty($fieldValue) || empty($value)) {
return false;
}
$today = date('Y-m-d');
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 98.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class VTJsonCondition
- Exclude checks
Avoid variables with short names like $sl. Configured minimum length is 3. Open
$sl = \strlen($str);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $sl. Configured minimum length is 3. Open
$sl = \strlen($str);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = 0;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
return $value === $fieldValue;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
return $fieldValue != $value;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
return $fieldValue == $value;
- 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 (\App\Record::isExists($referenceFieldId)) {
- 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
$i = 0;
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
} elseif ('Users' === \App\Fields\Owner::getType($referenceFieldId) && \App\User::getUserModel($referenceFieldId)->isActive()) {
- 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 = $this->checkCondition($referenceRecordModel, $cond, $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
public function evaluate($condition, Vtiger_Record_Model $recordModel)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$referenceRecordModel = Vtiger_Record_Model::getInstanceById($referenceFieldId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $condition
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($expr as $cond) {
- 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
$referenceField = $matches[1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$conditionGroup = $cond['groupid'];
- 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
$referenceModule = $matches[2];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Evaluate.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match('/(\w+) : \((\w+)\) (\w+)/', $cond['fieldname'], $matches);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($referenceFieldId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$groupResults = [];
- 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 ('Users' === \App\Fields\Owner::getType($referenceFieldId) && \App\User::getUserModel($referenceFieldId)->isActive()) {
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
$referenceRecordModel = Vtiger_Record_Model::getInstanceById($referenceFieldId, $referenceModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($expr)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 == \count($matches)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$expressionResults = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($conditionGroup)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldname = $matches[3];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cond['fieldname'] = $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
$expr = \App\Json::decode($condition);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$expressionResults[$conditionGroup][$i]['result'] = $this->checkCondition($recordModel, $cond);
- 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
* @param Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('Users' !== $referenceModule) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$referenceRecordModel = Vtiger_Record_Model::getInstanceById($referenceFieldId, $referenceModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = $this->checkCondition($referenceRecordModel, $cond, $recordModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$finalResult = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$conditionGroup = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$referenceFieldId = $recordModel->get($referenceField);
- 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
$logicalOperator = $groupResult['logicaloperator'];
- 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
$sl = \strlen($str);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($sl >= $ssl) {
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
public function checkCondition(Vtiger_Record_Model $recordModel, $cond, Vtiger_Record_Model $referredRecordModel = null)
- 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 (null !== $referredRecordModel) {
- 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
$fieldValue = $recordModel->get($fieldInstance->getName());
- Exclude checks
Line exceeds 120 characters; contains 147 characters Open
$expressionResults[$conditionGroup][$i + 1]['logicaloperator'] = (!empty($cond['joincondition'])) ? $cond['joincondition'] : 'and';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$logicalOperator = $exprResult['logicaloperator'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'and':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$finalResult = $result;
- 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
$fieldInstance = $recordModel->getModule()->getFieldByName($cond['fieldname']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('fieldname' === $expressionType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parser = new VTExpressionParser(new VTExpressionSpaceFilter(new VTExpressionTokenizer($value)));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\count($recordData) > 1) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($groupExprResultSet as &$exprResult) {
- 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
$groupResult = ($groupResult && $result);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($result)) { // Condition to skip last condition
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function startsWith($str, $subStr)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$ssl = \strlen($subStr);
- 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
$expressionType = $cond['valuetype'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$expression = $parser->expression();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$groupResult = ($groupResult || $result);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($logicalOperator) {
- 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
$dataType = $fieldInstance->getFieldDataType();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'date':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($logicalOperator)) {
- 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
$sl = \strlen($str);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 0 == substr_compare($str, $subStr, $sl - $ssl, $ssl);
- 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 condition.
- 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
$fieldValue = trim("$recordData[0] $recordData[1]");
- 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
$groupResults[$conditionGroup]['logicaloperator'] = (!empty($cond['groupjoin'])) ? $cond['groupjoin'] : 'and';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'and':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'or':
- 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
foreach ($groupResults as $groupId => &$groupResult) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = $groupResult['result'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$finalResult = ($finalResult && $result);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$expressionResults[$conditionGroup][$i + 1]['logicaloperator'] = (!empty($cond['joincondition'])) ? $cond['joincondition'] : 'and';
- 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
case 'or':
- 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
$ssl = \strlen($subStr);
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($sl >= $ssl) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function endsWith($str, $subStr)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Vtiger_Record_Model|null $referredRecordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $recordModel->get($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws Exception
- 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
switch ($dataType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = trim(html_entity_decode($cond['value'] ?? ''));
- 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
$groupResult = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($exprResult['result'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = $exprResult['result'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($result)) { // Condition to skip last condition
- 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
default:
- 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
* @param array $cond
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$condition = $cond['operation'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('datetime' === $dataType || 'date' === $dataType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $exprEvaluater->evaluate($referredRecordModel);
- 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
if (isset($exprResult['logicaloperator'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$groupResults[$groupId]['result'] = $groupResult;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else { // Case for the first condition
- 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
$rawFieldValue = $fieldValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$i;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('expression' === $expressionType) {
- 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
case 'accountName':
- 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
$finalResult = ($finalResult || $result);
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'datetime':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null !== $referredRecordModel) {
- 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
switch ($logicalOperator) {
- 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
$dateTimePair = ['date_start' => 'time_start', 'due_date' => 'time_end'];
- Exclude checks
Line exceeds 120 characters; contains 126 characters Open
$groupResults[$conditionGroup]['logicaloperator'] = (!empty($cond['groupjoin'])) ? $cond['groupjoin'] : 'and';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($expressionResults as $groupId => &$groupExprResultSet) {
- 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 false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldName = $cond['fieldname'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($dateTimePair[$fieldName]) && !$recordModel->isEmpty($dateTimePair[$fieldName])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $value === $fieldValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$expressionResults[$conditionGroup][$i]['result'] = $result;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($logicalOperator)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- 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
return 0 == substr_compare($str, $subStr, 0, $ssl);
- 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($condition) || false === $fieldInstance) {
- 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
require_once 'modules/com_vtiger_workflow/expression_engine/include.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$exprEvaluater = new VTFieldExpressionEvaluater($expression);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $exprEvaluater->evaluate($recordModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldValue = $recordModel->get($fieldInstance->getName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else { // Case for the first condition
- 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 $finalResult;
- 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
$value = $referredRecordModel->get($value);
- 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
$groupResult = $result;
- 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 false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function checkCondition(Vtiger_Record_Model $recordModel, $cond, Vtiger_Record_Model $referredRecordModel = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldValue = $recordModel->get($fieldName) . ' ' . $recordModel->get($dateTimePair[$fieldName]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldValue = $recordModel->get($fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldValue = $recordModel->get($cond['fieldname']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordData = explode('|##|', $fieldValue);
- 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 $value !== $fieldValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($val, $value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = [];
- 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
return $fieldValue < $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'greaterthannow':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fieldValue as $val) {
- 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
} elseif ($value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldValue == $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'does not contain hierarchy':
- 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
$value = date('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'is':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'contains':
- 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
case 'does not contain':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = \Settings_TreesManager_Record_Model::getChildren(implode('##', $value), $fieldInstance->getColumnName(), \Vtiger_Module_Model::getInstance($recordModel->getModule()->getName()));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'equal to':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'less than':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldValue > $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = Vtiger_MultiReferenceValue_UIType::COMMA . $value . Vtiger_MultiReferenceValue_UIType::COMMA;
- 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
$value = [$value];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
sort($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'time':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
sort($fieldValue);
- 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
$value = \Settings_TreesManager_Record_Model::getChildren(implode('##', $value), $fieldInstance->getColumnName(), \Vtiger_Module_Model::getInstance($recordModel->getModule()->getName()));
- 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 $result;
- 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
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldValueTemp = $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = explode(',', $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldValue = $recordModel->getDisplayValue($fieldInstance->getName(), false, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//strtotime condition is added for days before, days after where we give integer values, so strtotime will return 0 for such cases.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldValue = array_filter(explode(',', $fieldValue));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $value === $fieldValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = true;
- Exclude checks
Line exceeds 120 characters; contains 219 characters Open
$value = \Settings_TreesManager_Record_Model::getChildren(implode('##', $value), $fieldInstance->getColumnName(), \Vtiger_Module_Model::getInstance($recordModel->getModule()->getName()));
- 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 !empty(array_diff($value, $fieldValue));
- Exclude checks
Line exceeds 120 characters; contains 219 characters Open
$value = \Settings_TreesManager_Record_Model::getChildren(implode('##', $value), $fieldInstance->getColumnName(), \Vtiger_Module_Model::getInstance($recordModel->getModule()->getName()));
- 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
case 'greater than':
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
//strtotime condition is added for days before, days after where we give integer values, so strtotime will return 0 for such cases.
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$value = Vtiger_MultiReferenceValue_UIType::COMMA . $value . Vtiger_MultiReferenceValue_UIType::COMMA;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'multiReferenceValue':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'categoryMultipicklist':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return empty(array_diff($value, $fieldValue));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
sort($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\in_array($val, $value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== strpos($value, ',')) {
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//To avoid again checking whether it is user or not
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'reference':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
if (\in_array($condition, ['contains', 'contains hierarchy', 'does not contain', 'does not contain hierarchy', 'is', 'is not'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($condition) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'sharedOwner':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$condition = ('is' == $condition) ? 'contains' : 'does not contain';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($condition) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('between' !== $condition && strtotime($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'is not':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'contains hierarchy':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = explode('##', $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $result;
- 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
$fieldValue = $fieldValueTemp;
- 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
$value = \App\Fields\Date::formatToDb($value, true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $value . ':00'; // time fields will not have seconds appended to it, so we are adding
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$condition = ('is' == $condition) ? 'contains' : 'does not contain';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fieldValue as $val) {
- 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
$value = explode('##', $value);
- 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
}
- 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 ('is' === $condition || 'is not' === $condition) {
- 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
$value = ",{$value},";
- 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 (\in_array($condition, ['contains', 'contains hierarchy', 'does not contain', 'does not contain hierarchy', 'is', 'is not'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = array_filter(explode(',', $value));
- 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
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
sort($value);
- 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
if ('is' === $condition || 'is not' === $condition) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = explode(',', $fieldValue);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'owner':
- 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
$value = date('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'greater than or equal to':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldValue == $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldValue != $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return !\in_array($fieldValue, $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->endsWith($fieldValue, $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'has changed':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($fieldValue)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldValue < $value) {
- 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($fieldValue) || empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$olderDate = date('Y-m-d', strtotime('-' . $value . ' days'));
- 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 (empty($fieldValue) || empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$olderDate = date('Y-m-d', strtotime('-' . $value . ' days'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'does not equal':
- 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
$values = array_map('\App\Fields\Date::formatToDb', $values);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'off' === $fieldValue || 0 === $fieldValue || '0' === $fieldValue || '' === $fieldValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (preg_match('/([^:]+):boolean$/', $value, $match)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false === $recordModel->getPreviousValue($cond['fieldname']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'is not empty':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('datetime' === $dataType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldValue >= $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'more than days ago':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 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
$value = date('Y-m-d H:i:s');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($fieldValue) || empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'on' === $fieldValue || 1 === $fieldValue || '1' === $fieldValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'is not':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'does not contain':
- 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 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 $fieldValue != $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'starts with':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldValue >= $futureDate) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'not has changed':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'is empty':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'before':
- 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
case 'is today':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$futureDate = date('Y-m-d', strtotime('+' . $value . ' days'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'days ago':
- 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 ($fieldValue == $olderDate) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldValue <= $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (preg_match('/([^:]+):boolean$/', $value, $match)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->startsWith($fieldValue, $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$hasChanged = $recordModel->getPreviousValue($cond['fieldname']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldValue != $hasChanged;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'matches':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false === $hasChanged) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$values = explode(',', $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($olderDate <= $fieldValue && $fieldValue <= date('Y-m-d')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldValue == date('Y-m-d')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$olderDate = date('Y-m-d', strtotime('-' . $value . ' days'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($today <= $fieldValue && $fieldValue <= $futureDate) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'in less than':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 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 ('true' == $value) {
- 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 \in_array($fieldValue, $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 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 ($fieldValue > $values[0] && $fieldValue < $values[1]) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($fieldValue) || empty($value)) {
- 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
$value = $match[1];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'less than days ago':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('datetime' === $dataType) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false !== strpos($fieldValue, $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'ends with':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'after':
- 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 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
$value = date('Y-m-d H:i:s');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'is':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('true' == $value) {
- 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 true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($fieldValue)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldValue <= $olderDate) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($fieldValue) || empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldValue < $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'off' === $fieldValue || 0 === $fieldValue || '0' === $fieldValue || '' === $fieldValue;
- 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 (empty($fieldValue)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 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
}
- 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 false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'in more than':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldValue > $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'smallerthannow':
- 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
case 'contains':
- 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 false === strpos($fieldValue, $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$today = date('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $match[1];
- 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 'on' === $fieldValue || 1 === $fieldValue || '1' === $fieldValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($fieldValue)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'between':
- 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
case 'less than or equal to':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return preg_match($value, $fieldValue);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($fieldValue)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldValue > $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 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
$futureDate = date('Y-m-d', strtotime('+' . $value . ' days'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
return ($recordModel->isNew() || false !== $oldValue) && $recordModel->get($cond['fieldname']) == $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'is Not Watching Record':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'is record 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
$futureDate = date('Y-m-d', strtotime('+' . $value . ' days'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($rawFieldValue) || empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'more than hours later':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($watchdog->isWatchingRecord()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($watchdog->isWatchingRecord()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& \in_array($recordModel->get($fieldName), App\RecordStatus::getStates($recordModel->getModule()->getName(), \App\RecordStatus::RECORD_STATE_CLOSED))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'is Watching Record':
- 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
case 'days later':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($fieldValue) || empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'less than hours later':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 166 characters Open
&& \in_array($recordModel->get($fieldName), App\RecordStatus::getStates($recordModel->getModule()->getName(), \App\RecordStatus::RECORD_STATE_CLOSED))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Unexpected condition
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($olderDateTime <= $rawFieldValue && $rawFieldValue <= $currentTime) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$watchdog = Vtiger_Watchdog_Model::getInstanceById($recordModel->getId(), $recordModel->getModuleName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'less than hours before':
- 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 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
return (int) $value === \App\User::getCurrentUserId() ? false : true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
($fieldName = App\RecordStatus::getFieldName($recordModel->getModule()->getName()))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $recordModel->get($fieldInstance->getName()) !== $recordModel->get('created_user_id');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('Found an unexpected condition: ' . $condition);
- 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
$futureDateTime = date('Y-m-d H:i:s', strtotime('+' . $value . ' hours'));
- 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($rawFieldValue) || empty($value)) {
- 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
case 'has changed to':
- 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
&& \in_array($recordModel->get($fieldName), App\RecordStatus::getStates($recordModel->getModule()->getName(), \App\RecordStatus::RECORD_STATE_OPEN))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentTime = date('Y-m-d H:i:s');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$olderDateTime = date('Y-m-d H:i:s', strtotime('-' . $value . ' hours'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($currentTime <= $rawFieldValue && $rawFieldValue <= $futureDateTime) {
- 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
$watchdog = Vtiger_Watchdog_Model::getInstanceById($recordModel->getId(), $recordModel->getModuleName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'nom':
- 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
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($rawFieldValue) || empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($rawFieldValue >= $futureDateTime) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 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
case 'not created by owner':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$olderDateTime = date('Y-m-d H:i:s', strtotime('-' . $value . ' hours'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 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 (
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$oldValue = $recordModel->getPreviousValue($cond['fieldname']);
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$watchdog = Vtiger_Watchdog_Model::getInstanceById($recordModel->getId(), $recordModel->getModuleName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$watchdog = Vtiger_Watchdog_Model::getInstanceById($recordModel->getId(), $recordModel->getModuleName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
($fieldName = App\RecordStatus::getFieldName($recordModel->getModule()->getName()))
- Exclude checks
Line exceeds 120 characters; contains 164 characters Open
&& \in_array($recordModel->get($fieldName), App\RecordStatus::getStates($recordModel->getModule()->getName(), \App\RecordStatus::RECORD_STATE_OPEN))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($rawFieldValue) || empty($value)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldValue == $futureDate) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'om':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 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 true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (int) $value !== \App\User::getCurrentUserId() ? false : true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'is record closed':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 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
$currentTime = date('Y-m-d H:i:s');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'more than hours before':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($rawFieldValue <= $olderDateTime) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$futureDateTime = date('Y-m-d H:i:s', strtotime('+' . $value . ' hours'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return ($recordModel->isNew() || false !== $oldValue) && $recordModel->get($cond['fieldname']) == $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'accountName':
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'datetime':
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 20 Open
if (\count($recordData) > 1) {
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 20 Open
}
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 28 Open
case 'contains':
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 12 Open
}
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 20 Open
if ('is' === $condition || 'is not' === $condition) {
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'owner':
- Exclude checks
Line indented incorrectly; expected 32 spaces, found 36 Open
if (!\in_array($val, $value)) {
- Exclude checks
Closing brace indented incorrectly; expected 8 spaces, found 12 Open
}
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'date':
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 28 Open
case 'does not contain hierarchy':
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'sharedOwner':
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 20 Open
if (\in_array($condition, ['contains', 'contains hierarchy', 'does not contain', 'does not contain hierarchy', 'is', 'is not'])) {
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 24 Open
switch ($condition) {
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 32 Open
}
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 32 Open
foreach ($fieldValue as $val) {
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 28 Open
case 'does not contain':
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 24 Open
}
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 32 Open
}
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 20 Open
if ('is' === $condition || 'is not' === $condition) {
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
default:
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'time':
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 28 Open
case 'is':
- Exclude checks
Line indented incorrectly; expected 32 spaces, found 36 Open
}
- Exclude checks
Line indented incorrectly; expected 32 spaces, found 36 Open
}
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 20 Open
}
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 28 Open
default:
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 24 Open
if (false !== strpos($value, ',')) {
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 24 Open
} else {
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 20 Open
}
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'reference':
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 32 Open
}
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 20 Open
}
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'multiReferenceValue':
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 24 Open
} elseif ($value) {
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 28 Open
case 'contains hierarchy':
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 20 Open
}
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 32 Open
if (!empty($value)) {
- Exclude checks
Line indented incorrectly; expected 32 spaces, found 36 Open
if (\in_array($val, $value)) {
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 24 Open
}
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 20 Open
if ('between' !== $condition && strtotime($value)) {
- Exclude checks
Line indented incorrectly; expected 12 spaces, found 16 Open
case 'categoryMultipicklist':
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 32 Open
}
- Exclude checks
Line indented incorrectly; expected 24 spaces, found 28 Open
case 'is not':
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 32 Open
if (!empty($value)) {
- Exclude checks
Line indented incorrectly; expected 28 spaces, found 32 Open
foreach ($fieldValue as $val) {
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks