YetiForceCompany/YetiForceCRM

View on GitHub
modules/Users/models/RecordPopover.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

Method getHeaderLinks has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getHeaderLinks(): array
    {
        $links = [];
        $detailUrl = $this->recordModel->getFullDetailViewUrl();
        $editUrl = $this->recordModel->isEditable() ? $this->recordModel->getEditViewUrl() : '';
Severity: Minor
Found in modules/Users/models/RecordPopover.php - About 1 hr to fix

    Avoid using static access to class 'Vtiger_Link_Model' in method 'getHeaderLinks'.
    Open

                $linksModels[] = Vtiger_Link_Model::getInstanceFromValues($link);

    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

            if (\App\User::getCurrentUserModel()->isAdmin() && $this->recordModel->isEditable()) {
    Severity: Critical
    Found in modules/Users/models/RecordPopover.php by phan

    Each class must be in a namespace of at least one level (a top-level vendor name)
    Open

    class Users_RecordPopover_Model extends Vtiger_RecordPopover_Model

    The class Users_RecordPopover_Model is not named in CamelCase.
    Open

    class Users_RecordPopover_Model extends Vtiger_RecordPopover_Model
    {
        /** {@inheritdoc} */
        public function getFields(): array
        {

    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

                    $summaryFields[$fieldName] = $fieldModel;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linktype' => 'RECORD_POPOVER_VIEW',

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linklabel' => 'LBL_EDIT',

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linktype' => 'RECORD_POPOVER_VIEW',

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linkhref' => true,

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $summaryFields;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linkurl' => $editUrl,

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linkurl' => $detailUrl,

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function getFields(): array

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linkicon' => 'yfi yfi-full-editing-view',

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linkicon' => 'fas fa-th-list',

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $summaryFields = [];

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public function getHeaderLinks(): array

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (\App\User::getCurrentUserModel()->isAdmin() && $this->recordModel->isEditable()) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $links[] = [

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linkclass' => 'btn-sm btn-outline-secondary',

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $editUrl = $this->recordModel->isEditable() ? $this->recordModel->getEditViewUrl() : '';

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linkhref' => true,

    Spaces must be used to indent lines; tabs are not allowed
    Open

                ];

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linklabel' => 'DetailView',

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    'linkclass' => 'btn-sm btn-outline-secondary',

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $detailUrl = $this->recordModel->getFullDetailViewUrl();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if ($this->recordModel->isViewable()) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $linksModels[] = Vtiger_Link_Model::getInstanceFromValues($link);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $linksModels = [];

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $links = [];

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $links[] = [

    Spaces must be used to indent lines; tabs are not allowed
    Open

            foreach ($links as $link) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /** {@inheritdoc} */

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $fieldModel = $fields[$fieldName];

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $linksModels;

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $fields = $this->recordModel->getModule()->getFields();

    Spaces must be used to indent lines; tabs are not allowed
    Open

            foreach (['first_name', 'last_name', 'roleid', 'email1', 'primary_phone'] as $fieldName) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                if ($fieldModel && !$this->recordModel->isEmpty($fieldName) && $fieldModel->isViewableInDetailView()) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                ];

    Class name "Users_RecordPopover_Model" is not in camel caps format
    Open

    class Users_RecordPopover_Model extends Vtiger_RecordPopover_Model

    There are no issues that match your filters.

    Category
    Status