modules/ModComments/models/Relation.php
The method addRelation has a boolean flag argument $params, which is a certain sign of a Single Responsibility Principle violation. Open
Open
public function addRelation($sourceRecordId, $destinationRecordIds, $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
Missing class import via use statement (line '29', column '23'). Open
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
Avoid using static access to class '\CRMEntity' in method 'addRelation'. Open
Open
\CRMEntity::trackLinkedInfo($sourceRecordId);
- 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
Argument 1 (moduleName)
is false
but \App\EventHandler::setModuleName()
takes string
defined at /code/app/EventHandler.php:366
Open
Open
$eventHandler->setModuleName($sourceModuleName);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class ModComments_Relation_Model extends Vtiger_Relation_Model
- Exclude checks
The class ModComments_Relation_Model is not named in CamelCase. Open
Open
class ModComments_Relation_Model extends Vtiger_Relation_Model
{
/** {@inheritdoc} */
public function addRelation($sourceRecordId, $destinationRecordIds, $params = false)
{
- 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
Open
foreach ($destinationRecordIds as $destinationRecordId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$eventHandler->setParams($data);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function addRelation($sourceRecordId, $destinationRecordIds, $params = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$data = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$result = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (!\is_array($destinationRecordIds)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function setExceptionData()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'sourceRecordId' => $sourceRecordId,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'destinationModule' => $this->getRelationModuleModel()->getName(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'sourceModule' => $sourceModuleName,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$data['destinationRecordId'] = $destinationRecordId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Set exceptional data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'name' => 'getRelatedRecord',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$eventHandler = new \App\EventHandler();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $result;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'actions' => '',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->setData($data);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'CRMEntity' => $this->getParentModuleModel()->getEntityInstance(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$eventHandler->setModuleName($sourceModuleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$sourceModuleName = $this->getParentModuleModel()->getName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$destinationRecordIds = [$destinationRecordIds];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'related_tabid' => $this->getRelationModuleModel()->getId(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'modulename' => $this->getParentModuleModel()->getName(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$data = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$eventHandler->trigger('EntityBeforeLink');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
\CRMEntity::trackLinkedInfo($sourceRecordId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$eventHandler->trigger('EntityAfterLink');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'tabid' => $this->getParentModuleModel()->getId(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Class name "ModComments_Relation_Model" is not in camel caps format Open
Open
class ModComments_Relation_Model extends Vtiger_Relation_Model
- Exclude checks