YetiForceCompany/YetiForceCRM

View on GitHub
modules/HolidaysEntitlement/HolidaysEntitlement.php

Summary

Maintainability
A
0 mins
Test Coverage
F
42%

The class HolidaysEntitlement has 16 fields. Consider redesigning HolidaysEntitlement to keep the number of fields under 15.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

TooManyFields

Since: 0.1

Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

Example

class Person {
   protected $one;
   private $two;
   private $three;
   [... many more fields ...]
}

Source https://phpmd.org/rules/codesize.html#toomanyfields

Avoid unused parameters such as '$moduleName'.
Open

    public function moduleHandler($moduleName, $eventType)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Saw possibly unextractable annotation for a fragment of comment '* @param string Event Type': after string, did not see an element name (will guess based on comment order)
Open

     * @param string Event Type

Saw possibly unextractable annotation for a fragment of comment '* @param string Module name': after string, did not see an element name (will guess based on comment order)
Open

     * @param string Module name

Call to undeclared method \App\Db::createCommand
Open

            \App\Db::getInstance()->createCommand()->update('vtiger_tab', ['customized' => 0], ['name' => 'HolidaysEntitlement'])->execute();

Avoid using static access to class 'vtlib\Module' in method 'moduleHandler'.
Open

            $moduleInstance = vtlib\Module::getInstance('HolidaysEntitlement');

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

Avoid using static access to class 'vtlib\Module' in method 'moduleHandler'.
Open

            $targetModule = vtlib\Module::getInstance('OSSEmployees');

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

Define a constant instead of duplicating this literal "assigned_user_id" 3 times.
Open

        'Assigned To' => 'assigned_user_id',

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.

Define a constant instead of duplicating this literal "vtiger_holidaysentitlement" 3 times.
Open

    public $table_name = 'vtiger_holidaysentitlement';

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.

Define a constant instead of duplicating this literal "ossemployeesid" 6 times.
Open

        'LBL_EMPLOYEE' => 'ossemployeesid',

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.

Define a constant instead of duplicating this literal "HolidaysEntitlement" 3 times.
Open

            \App\Db::getInstance()->createCommand()->update('vtiger_tab', ['customized' => 0], ['name' => 'HolidaysEntitlement'])->execute();

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.

Define a constant instead of duplicating this literal "holidaysentitlementid" 4 times.
Open

    public $table_index = 'holidaysentitlementid';

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.

Define a constant instead of duplicating this literal "vtiger_holidaysentitlementcf" 3 times.
Open

    public $customFieldTable = ['vtiger_holidaysentitlementcf', 'holidaysentitlementid'];

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.

Avoid excessively long variable names like $def_detailview_recname. Keep variable name length under 20.
Open

    public $def_detailview_recname = 'ossemployeesid';

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

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

class HolidaysEntitlement extends Vtiger_CRMEntity

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 13 and the first side effect is on line 8.
Open

<?php

The property $default_sort_order is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $search_fields_name is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $mandatory_fields is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $column_fields is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $popup_fields is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $tab_name_index is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $tab_name is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $default_order_by is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $def_detailview_recname is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $search_fields is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $table_name is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $table_index is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $def_basicsearch_col is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

The property $list_fields_name is not named in camelCase.
Open

class HolidaysEntitlement extends Vtiger_CRMEntity
{
    /**
     * Table name.
     *

CamelCasePropertyName

Since: 0.2

It is considered best practice to use the camelCase notation to name attributes.

Example

class ClassName {
    protected $property_name;
}

Source

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

     * Table name.

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

     * Table index.

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

     * @var string

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

     *

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

        'Assigned To' => 'assigned_user_id',

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

        // Format: Field Label => Array(tablename, columnname)

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

     * Mandatory table for supporting custom fields.

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

     *

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

        'LBL_EMPLOYEE' => ['holidaysentitlement', 'ossemployeesid'],

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

     * @var string

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

     * @var array

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

     *  List of fields in the RelationListView.

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

    public $tab_name_index = [

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

     * List fields name.

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

     * @var array

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

    public $table_index = 'holidaysentitlementid';

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

    /**

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

        'LBL_EMPLOYEE' => 'ossemployeesid',

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

    public $search_fields = [

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

        // tablename should not have prefix 'vtiger_'

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

    /**

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

     * Column fields.

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

    public $column_fields = [];

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

     *

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

     * @var array

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

     * For Popup listview and UI type support.

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 $tab_name = ['vtiger_crmentity', 'vtiger_holidaysentitlement', 'vtiger_holidaysentitlementcf'];

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

     * Mandatory for Saving, Include tablename and tablekey columnname here.

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

     * @var array

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

     * @var string[]

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 $popup_fields = ['ossemployeesid'];

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

    /**

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

     * @var array

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

    /**

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

        'vtiger_holidaysentitlement' => 'holidaysentitlementid',

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

     */

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

     * @var array

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

     * @var array

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

    /**

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

        'vtiger_holidaysentitlementcf' => 'holidaysentitlementid', ];

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

        'LBL_NO' => ['holidaysentitlement', 'holidaysentitlement_no'],

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

        'Assigned To' => ['crmentity', 'assigned_user_id'],

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

     * @var array

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

        'vtiger_crmentity' => 'crmid',

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

    public $list_fields_name = [

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

        'LBL_NO' => 'holidaysentitlement_no',

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

     * Mandatory for Saving, Include tables related to this module.

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 $relationFields = [];

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

     * For Popup window record selection.

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

    public $def_basicsearch_col = 'ossemployeesid';

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

     */

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

        // Format: Field Label => 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

     */

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

    public $search_fields_name = [];

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

     * @var string

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

     *

Line exceeds 120 characters; contains 141 characters
Open

            \App\Db::getInstance()->createCommand()->update('vtiger_tab', ['customized' => 0], ['name' => 'HolidaysEntitlement'])->execute();

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

        if ('module.postinstall' === $eventType) {

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

    public $def_detailview_recname = 'ossemployeesid';

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

            $moduleInstance = vtlib\Module::getInstance('HolidaysEntitlement');

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

     * @var array

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

            $targetModule = vtlib\Module::getInstance('OSSEmployees');

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 $default_order_by = '';

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

     * Default sort order.

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

     *

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

     * Invoked when special actions are performed on the module.

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

     * @param string Event Type

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 moduleHandler($moduleName, $eventType)

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

     */

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

     * @var string

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

     * @param mixed $moduleName

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

            $targetModule->setRelatedList($moduleInstance, 'HolidaysEntitlement', ['ADD'], 'getDependentsList');

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

    public $default_sort_order = 'ASC';

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

    public $table_name = 'vtiger_holidaysentitlement';

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

    public $customFieldTable = ['vtiger_holidaysentitlementcf', 'holidaysentitlementid'];

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

     * Search fields name.

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

     */

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

     * For Alphabetical search.

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

     * @var string

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

     * Used when enabling/disabling the mandatory fields for the module. Refers to vtiger_field.fieldname values.

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

     * Column value to use on detail view record text display.

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

     *

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

     * @var string

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

     * @param mixed $eventType

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

    public $mandatory_fields = ['ossemployeesid', 'assigned_user_id', 'holidaysentitlement_year', 'days'];

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

            \App\Db::getInstance()->createCommand()->update('vtiger_tab', ['customized' => 0], ['name' => 'HolidaysEntitlement'])->execute();

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

     * Default order by.

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

     * @param string Module name

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

    /**

There are no issues that match your filters.

Category
Status