modules/Settings/SlaPolicy/models/Module.php
Define a constant instead of duplicating this literal "ServiceContracts" 5 times. Open
Open
'operational_hours' => ['LBL_OPERATIONAL_HOURS', 'ServiceContracts'],
- 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.
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Settings_SlaPolicy_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks
The class Settings_SlaPolicy_Module_Model is not named in CamelCase. Open
Open
class Settings_SlaPolicy_Module_Model extends Settings_Vtiger_Module_Model
{
/**
* Base table.
*
- 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
* Base index.
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'tabid' => 'LBL_SOURCE_MODULE',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'resolve_time' => ['LBL_RESOLVE_TIME', 'ServiceContracts'],
- 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
'business_hours' => ['LBL_BUSINESS_HOURS', 'ServiceContracts']
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getDefaultUrl()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* List fields.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public $name = 'SlaPolicy';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Base table.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public $baseTable = 's_#__sla_policy';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Get edit record url.
- 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
public $listFields = [
- 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
{
- 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
'idle_time' => ['LBL_IDLE_TIME', 'ServiceContracts'],
- 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
return 'index.php?module=SlaPolicy&parent=Settings&view=Edit';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'name' => 'LBL_NAME',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'operational_hours' => ['LBL_OPERATIONAL_HOURS', 'ServiceContracts'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Module name.
- 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
/**
- 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
return 'index.php?module=SlaPolicy&parent=Settings&view=List';
- 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public $baseIndex = 'id';
- 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
* @var string
- 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
* @param int $recordId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @var array
- 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
* @return string
- 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
'reaction_time' => ['LBL_REACTION_TIME', 'ServiceContracts'],
- 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
public function getCreateRecordUrl()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getEditRecordUrl(int $recordId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return 'index.php?module=SlaPolicy&parent=Settings&view=Edit&record=' . $recordId;
- Exclude checks
Class name "Settings_SlaPolicy_Module_Model" is not in camel caps format Open
Open
class Settings_SlaPolicy_Module_Model extends Settings_Vtiger_Module_Model
- Exclude checks