modules/Users/models/RecordPopover.php
Method getHeaderLinks
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getHeaderLinks(): array
{
$links = [];
$detailUrl = $this->recordModel->getFullDetailViewUrl();
$editUrl = $this->recordModel->isEditable() ? $this->recordModel->getEditViewUrl() : '';
Avoid using static access to class 'Vtiger_Link_Model' in method 'getHeaderLinks'. Open
Open
$linksModels[] = Vtiger_Link_Model::getInstanceFromValues($link);
- 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 method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
Open
if (\App\User::getCurrentUserModel()->isAdmin() && $this->recordModel->isEditable()) {
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Users_RecordPopover_Model extends Vtiger_RecordPopover_Model
- Exclude checks
The class Users_RecordPopover_Model is not named in CamelCase. Open
Open
class Users_RecordPopover_Model extends Vtiger_RecordPopover_Model
{
/** {@inheritdoc} */
public function getFields(): array
{
- 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
$summaryFields[$fieldName] = $fieldModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'linktype' => 'RECORD_POPOVER_VIEW',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'linklabel' => 'LBL_EDIT',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'linktype' => 'RECORD_POPOVER_VIEW',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'linkhref' => 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
return $summaryFields;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'linkurl' => $editUrl,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'linkurl' => $detailUrl,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getFields(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'linkicon' => 'yfi yfi-full-editing-view',
- 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
'linkicon' => 'fas fa-th-list',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$summaryFields = [];
- 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 getHeaderLinks(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (\App\User::getCurrentUserModel()->isAdmin() && $this->recordModel->isEditable()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$links[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'linkclass' => 'btn-sm btn-outline-secondary',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$editUrl = $this->recordModel->isEditable() ? $this->recordModel->getEditViewUrl() : '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'linkhref' => 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
'linklabel' => 'DetailView',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'linkclass' => 'btn-sm btn-outline-secondary',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$detailUrl = $this->recordModel->getFullDetailViewUrl();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($this->recordModel->isViewable()) {
- 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
$linksModels[] = Vtiger_Link_Model::getInstanceFromValues($link);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$linksModels = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$links = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$links[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
foreach ($links as $link) {
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$fieldModel = $fields[$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
return $linksModels;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$fields = $this->recordModel->getModule()->getFields();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
foreach (['first_name', 'last_name', 'roleid', 'email1', 'primary_phone'] as $fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($fieldModel && !$this->recordModel->isEmpty($fieldName) && $fieldModel->isViewableInDetailView()) {
- 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
Class name "Users_RecordPopover_Model" is not in camel caps format Open
Open
class Users_RecordPopover_Model extends Vtiger_RecordPopover_Model
- Exclude checks