modules/API/handlers/CardDAV.php
Avoid using static access to class '\App\Integrations\Dav\Card' in method 'entityAfterDelete'. Open
Open
\App\Integrations\Dav\Card::deleteByCrmId($eventHandler->getRecordModel()->getId());
- 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
Call to undeclared method \App\Db::createCommand
Open
Open
\App\Db::getInstance()->createCommand()
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
Open
\App\Db::getInstance()->createCommand()
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class API_CardDAV_Handler
- Exclude checks
The class API_CardDAV_Handler is not named in CamelCase. Open
Open
class API_CardDAV_Handler
{
/**
* @var array CardDav fields structure.
*/
- 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
* @var array CardDav fields structure.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
const TABLES = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($isNew) {
- 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 = $eventHandler->getModuleName();
- 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
'firstname', 'lastname', 'email', 'secondary_email', 'phone', 'mobile', 'description', 'jobtitle', 'addresslevel1a', 'addresslevel2a', 'addresslevel3a', 'addresslevel4a', 'addresslevel5a', 'addresslevel6a', 'addresslevel7a', 'addresslevel8a', 'addresslevel1b', 'addresslevel2b', 'addresslevel3b', 'addresslevel4b', 'addresslevel5b', 'addresslevel6b', 'addresslevel7b', 'addresslevel8b', 'localnumbera', 'localnumberb'
- Exclude checks
Line exceeds 120 characters; contains 266 characters Open
Open
'name', 'last_name', 'business_phone', 'business_mail', 'private_phone', 'private_mail', 'description', 'company_name', 'street', 'city', 'state', 'code', 'country', 'ship_street', 'ship_city', 'ship_state', 'ship_code', 'ship_country', 'secondary_phone'
- 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 array CardDav tables structure.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* EntityAfterSave handler function.
- 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 entityAfterSave(App\EventHandler $eventHandler)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$info = static::TABLES[$moduleName];
- 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
\App\Db::getInstance()->createCommand()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Line exceeds 120 characters; contains 429 characters Open
Open
'firstname', 'lastname', 'email', 'secondary_email', 'phone', 'mobile', 'description', 'jobtitle', 'addresslevel1a', 'addresslevel2a', 'addresslevel3a', 'addresslevel4a', 'addresslevel5a', 'addresslevel6a', 'addresslevel7a', 'addresslevel8a', 'addresslevel1b', 'addresslevel2b', 'addresslevel3b', 'addresslevel4b', 'addresslevel5b', 'addresslevel6b', 'addresslevel7b', 'addresslevel8b', 'localnumbera', 'localnumberb'
- 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 = $eventHandler->getModuleName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$isNew = $recordModel->isNew();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
\App\Db::getInstance()->createCommand()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return true;
- 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
* EntityAfterDelete handler function.
- 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
if (isset(static::TABLES[$moduleName])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
const FIELDS = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'name', 'last_name', 'business_phone', 'business_mail', 'private_phone', 'private_mail', 'description', 'company_name', 'street', 'city', 'state', 'code', 'country', 'ship_street', 'ship_city', 'ship_state', 'ship_code', 'ship_country', 'secondary_phone'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$recordModel = $eventHandler->getRecordModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
foreach (static::FIELDS[$moduleName] as $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
->update($info[0], ['dav_status' => 1], [$info[1] => $recordModel->getId()])->execute();
- 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 App\EventHandler $eventHandler
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param \App\EventHandler $eventHandler
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function entityChangeState(App\EventHandler $eventHandler)
- 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 entityAfterDelete(App\EventHandler $eventHandler)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* EntityChangeState handler function.
- 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 \App\EventHandler $eventHandler
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$row = static::TABLES[$moduleName];
- 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
->update($row[0], ['dav_status' => 1], [$row[1] => $eventHandler->getRecordModel()->getId()])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'Contacts' => ['vtiger_contactdetails', 'contactid'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return true;
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
Open
->update($row[0], ['dav_status' => 1], [$row[1] => $eventHandler->getRecordModel()->getId()])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'OSSEmployees' => [
- 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'Contacts' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$delta = $recordModel->getPreviousValue();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (isset($delta[$fieldName])) {
- 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
'OSSEmployees' => ['vtiger_ossemployees', 'ossemployeesid'],
- 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
\App\Integrations\Dav\Card::deleteByCrmId($eventHandler->getRecordModel()->getId());
- Exclude checks
Class name "API_CardDAV_Handler" is not in camel caps format Open
Open
class API_CardDAV_Handler
- Exclude checks