Method addRelation
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addRelation($sourceRecordId, $destinationRecordId, $params = false)
{
$return = false;
if (!\is_array($destinationRecordId)) {
$destinationRecordId = [$destinationRecordId];
Missing class import via use statement (line '28', column '49'). Open
$relationModel = empty($this->getData) ? (new OSSMailView_GetRecordToMails_Relation()) : $this->getTypeRelationModel();
- 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 '41', column '24'). Open
$eventHandler = new App\EventHandler();
- 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
The method addRelation has a boolean flag argument $params, which is a certain sign of a Single Responsibility Principle violation. Open
public function addRelation($sourceRecordId, $destinationRecordId, $params = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid using static access to class 'CRMEntity' in method 'addRelation'. Open
'CRMEntity' => CRMEntity::getInstance($destinationModuleName),
- 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 'CRMEntity' in method 'addRelation'. Open
CRMEntity::trackLinkedInfo($crmId);
- 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 'addRelation'. Open
$destinationModuleName = \App\Record::getType($crmId);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '45', column '8'). Open
public function addRelation($sourceRecordId, $destinationRecordId, $params = false)
{
$return = false;
if (!\is_array($destinationRecordId)) {
$destinationRecordId = [$destinationRecordId];
- 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
Reference to undeclared property \OSSMailView_Relation_Model->getData
(Did you mean \OSSMailView_Relation_Model->getData()) Open
$relationModel = empty($this->getData) ? (new OSSMailView_GetRecordToMails_Relation()) : $this->getTypeRelationModel();
- Exclude checks
Reference to undeclared property \OSSMailView_GetRecordToMails_Relation->date
Open
$relationModel->date = $params;
- Exclude checks
Reference to undeclared property \App\Relation\RelationAbstraction->date
Open
$relationModel->date = $params;
- Exclude checks
Avoid excessively long variable names like $destinationModuleName. Keep variable name length under 20. Open
$destinationModuleName = \App\Record::getType($crmId);
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class OSSMailView_Relation_Model extends Vtiger_Relation_Model
- Exclude checks
The class OSSMailView_Relation_Model is not named in CamelCase. Open
class OSSMailView_Relation_Model extends Vtiger_Relation_Model
{
/**
* Add relation.
*
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
* @param int|int[] $destinationRecordId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $params
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$destinationModuleName = \App\Record::getType($crmId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$eventHandler->trigger('EntityAfterLink');
- 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
'destinationModule' => 'OSSMailView',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$eventHandler->setParams($data);
- 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
'destinationRecordId' => $sourceRecordId,
- 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_array($destinationRecordId)) {
- 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
$relationModel->date = $params;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Add relation.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationModel = empty($this->getData) ? (new OSSMailView_GetRecordToMails_Relation()) : $this->getTypeRelationModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($params) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
$relationModel = empty($this->getData) ? (new OSSMailView_GetRecordToMails_Relation()) : $this->getTypeRelationModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($destinationRecordId as $crmId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
CRMEntity::trackLinkedInfo($crmId);
- 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
'sourceModule' => $destinationModuleName,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($return = $relationModel->create($sourceRecordId, $crmId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$destinationRecordId = [$destinationRecordId];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $sourceRecordId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$eventHandler = new App\EventHandler();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$eventHandler->setModuleName($destinationModuleName);
- 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 addRelation($sourceRecordId, $destinationRecordId, $params = 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
$data = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $return;
- 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
'CRMEntity' => CRMEntity::getInstance($destinationModuleName),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sourceRecordId' => $crmId,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$eventHandler->trigger('EntityBeforeLink');
- Exclude checks
Class name "OSSMailView_Relation_Model" is not in camel caps format Open
class OSSMailView_Relation_Model extends Vtiger_Relation_Model
- Exclude checks