YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/Wapro/models/Activation.php

Summary

Maintainability
B
4 hrs
Test Coverage
F
0%

Method activate has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function activate(): bool
    {
        $importer = new \App\Db\Importers\Base();
        $db = \App\Db::getInstance();
        if (!$db->isTableExists(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME)) {
Severity: Major
Found in modules/Settings/Wapro/models/Activation.php - About 2 hrs to fix

    Function activate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function activate(): bool
        {
            $importer = new \App\Db\Importers\Base();
            $db = \App\Db::getInstance();
            if (!$db->isTableExists(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME)) {
    Severity: Minor
    Found in modules/Settings/Wapro/models/Activation.php - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function check has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function check(): bool
        {
            $db = \App\Db::getInstance();
            $check = $db->isTableExists(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME) && $db->isTableExists(\App\Integrations\Wapro::LOG_TABLE_NAME);
            if ($check) {
    Severity: Minor
    Found in modules/Settings/Wapro/models/Activation.php - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Missing class import via use statement (line '90', column '18').
    Open

                $check = (new \App\Db\Query())->from('vtiger_field')->where(['tabid' => $moduleId, 'fieldname' => $field[0]])->exists();

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '39', column '19').
    Open

                    $check = (new \App\Db\Query())->from('vtiger_field')->where(['tabid' => \App\Module::getModuleId($field[1]), 'fieldname' => $field[0]])->exists();

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '62', column '19').
    Open

            $importer = new \App\Db\Importers\Base();

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '49', column '17').
    Open

                $cron = (new \App\Db\Query())->from('vtiger_cron_task')->where(['name' => 'LBL_INTEGRATION_WAPRO', 'handler_class' => 'Vtiger_IntegrationWapro_Cron'])->one();

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '139', column '16').
    Open

            $cron = (new \App\Db\Query())->from('vtiger_cron_task')->where(['name' => 'LBL_INTEGRATION_WAPRO', 'handler_class' => 'Vtiger_IntegrationWapro_Cron'])->one();

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '97', column '26').
    Open

                    $fieldInstance = new Vtiger_Field_Model();

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Avoid using static access to class '\App\Module' in method 'check'.
    Open

                    $check = (new \App\Db\Query())->from('vtiger_field')->where(['tabid' => \App\Module::getModuleId($field[1]), 'fieldname' => $field[0]])->exists();

    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 '\App\Db' in method 'activate'.
    Open

            $db = \App\Db::getInstance();

    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\Cron' in method 'activateCron'.
    Open

                \vtlib\Cron::register('LBL_INTEGRATION_WAPRO', 'Vtiger_IntegrationWapro_Cron', 900, 'Vtiger', 1);

    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 '\App\Cron' in method 'activateCron'.
    Open

                \App\Cron::updateStatus(\App\Cron::STATUS_ENABLED, 'LBL_INTEGRATION_WAPRO');

    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\Block' in method 'activate'.
    Open

                    $blockModel = vtlib\Block::getInstance($field[2], $field[1]);

    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\Block' in method 'activate'.
    Open

                        $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance($field[1]));

    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 'Vtiger_Inventory_Model' in method 'activateInventory'.
    Open

            $inventory = Vtiger_Inventory_Model::getInstance('FInvoice');

    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 '\App\Module' in method 'activate'.
    Open

                $moduleId = \App\Module::getModuleId($field[1]);

    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 '\App\Db' in method 'check'.
    Open

            $db = \App\Db::getInstance();

    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 'activate'.
    Open

                        $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance($field[1]));

    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

    The method activate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                    } else {
                        $status = false;
                    }

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

    Source https://phpmd.org/rules/cleancode.html#elseexpression

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

                $cron = (new \App\Db\Query())->from('vtiger_cron_task')->where(['name' => 'LBL_INTEGRATION_WAPRO', 'handler_class' => 'Vtiger_IntegrationWapro_Cron'])->one();

    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_IntegrationWapro_Cron" 3 times.
    Open

                $cron = (new \App\Db\Query())->from('vtiger_cron_task')->where(['name' => 'LBL_INTEGRATION_WAPRO', 'handler_class' => 'Vtiger_IntegrationWapro_Cron'])->one();

    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 "LBL_CUSTOM_INFORMATION" 4 times.
    Open

            ['wapro_id', 'BankAccounts', 'LBL_CUSTOM_INFORMATION'],

    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 "FInvoice" 3 times.
    Open

            ['wapro_id', 'FInvoice', 'LBL_CUSTOM_INFORMATION'],

    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 "tabid" 3 times.
    Open

                    $check = (new \App\Db\Query())->from('vtiger_field')->where(['tabid' => \App\Module::getModuleId($field[1]), 'fieldname' => $field[0]])->exists();

    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 "wapro_id" 7 times.
    Open

            ['wapro_id', 'MultiCompany', 'LBL_SYSTEM_INFORMATION'],

    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 "crmid" 4 times.
    Open

                    'crmid' => $importer->integer(10)->notNull(),

    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.

    Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
    Open

                    'wtable' => $importer->stringType('50')->notNull(),

    Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
    Open

                    'time' => $importer->dateTime()->notNull(),

    Call to undeclared method \App\Db\Query::from
    Open

                $check = (new \App\Db\Query())->from('vtiger_field')->where(['tabid' => $moduleId, 'fieldname' => $field[0]])->exists();

    Call to undeclared method \App\Db\Query::from
    Open

            $cron = (new \App\Db\Query())->from('vtiger_cron_task')->where(['name' => 'LBL_INTEGRATION_WAPRO', 'handler_class' => 'Vtiger_IntegrationWapro_Cron'])->one();

    Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
    Open

                    'crmid' => $importer->integer(10)->notNull(),

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

                $db->createCommand()->createIndex(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME . '_crmid_idx', \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'crmid', true)->execute();

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

                $db->createCommand()->createIndex(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME . '_wapro_idx', \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'wtable,wid')->execute();

    Call to undeclared method \App\Db\Query::from
    Open

                    $check = (new \App\Db\Query())->from('vtiger_field')->where(['tabid' => \App\Module::getModuleId($field[1]), 'fieldname' => $field[0]])->exists();

    Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
    Open

                    'wid' => $importer->integer(10)->notNull(),

    Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
    Open

                        ->set('columntype', $importer->integer(10)->notNull())

    Argument 1 (length) is '50' but \App\Db\Importers\Base::stringType() takes int defined at /code/app/Db/Importers/Base.php:141
    Open

                    'wtable' => $importer->stringType('50')->notNull(),

    Call to undeclared method \App\Db\Query::from
    Open

                $cron = (new \App\Db\Query())->from('vtiger_cron_task')->where(['name' => 'LBL_INTEGRATION_WAPRO', 'handler_class' => 'Vtiger_IntegrationWapro_Cron'])->one();

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

                $db->createCommand()->addForeignKey(

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

    class Settings_Wapro_Activation_Model

    Avoid variables with short names like $db. Configured minimum length is 3.
    Open

            $db = \App\Db::getInstance();

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

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

    Avoid variables with short names like $db. Configured minimum length is 3.
    Open

            $db = \App\Db::getInstance();

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

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

    The class Settings_Wapro_Activation_Model is not named in CamelCase.
    Open

    class Settings_Wapro_Activation_Model
    {
        /** @var array Map relation table name */
        private const FIELDS = [
            ['wapro_id', 'MultiCompany', 'LBL_SYSTEM_INFORMATION'],

    CamelCaseClassName

    Since: 0.2

    It is considered best practice to use the CamelCase notation to name classes.

    Example

    class class_name {
    }

    Source

    Only one argument is allowed per line in a multi-line function call
    Open

                    'fk_1_' . \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'

    Only one argument is allowed per line in a multi-line function call
    Open

                    'fk_1_' . \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'

    Only one argument is allowed per line in a multi-line function call
    Open

                    'fk_1_' . \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'

    Only one argument is allowed per line in a multi-line function call
    Open

                    'fk_1_' . \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'

    Only one argument is allowed per line in a multi-line function call
    Open

                    'fk_1_' . \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'

    Only one argument is allowed per line in a multi-line function call
    Open

                    'fk_1_' . \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'

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

                    $check = (new \App\Db\Query())->from('vtiger_field')->where(['tabid' => \App\Module::getModuleId($field[1]), 'fieldname' => $field[0]])->exists();

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

            }

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

         * Activate integration, requires creation of additional integration data.

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

            $importer = new \App\Db\Importers\Base();

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

            $db = \App\Db::getInstance();

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

                    'id' => $importer->primaryKeyUnsigned(),

    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

         * Activate integration in inventory.

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

            if (empty($cron)) {

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

            if (1 != $cron['status']) {

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

            ['wapro_id', 'BankAccounts', 'LBL_CUSTOM_INFORMATION'],

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

                }

    Line exceeds 120 characters; contains 170 characters
    Open

                $cron = (new \App\Db\Query())->from('vtiger_cron_task')->where(['name' => 'LBL_INTEGRATION_WAPRO', 'handler_class' => 'Vtiger_IntegrationWapro_Cron'])->one();

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

         */

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

                $db->createCommand()->addForeignKey(

    Line exceeds 120 characters; contains 132 characters
    Open

                $check = (new \App\Db\Query())->from('vtiger_field')->where(['tabid' => $moduleId, 'fieldname' => $field[0]])->exists();

    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

            $fieldModel->setDefaultDataConfig();

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

            }

    Line exceeds 120 characters; contains 148 characters
    Open

            $check = $db->isTableExists(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME) && $db->isTableExists(\App\Integrations\Wapro::LOG_TABLE_NAME);

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

                foreach (self::FIELDS as $field) {

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

                    }

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

                        ->set('table', $db->quoteSql(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME))

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

                    } else {

    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

            ['wapro_id', 'Contacts', 'LBL_CUSTOM_INFORMATION'],

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

                $check = $cron && 1 == $cron['status'];

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

            return $check;

    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 bool

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

                $db->createTable(\App\Integrations\Wapro::LOG_TABLE_NAME, [

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

                    'time' => $importer->dateTime()->notNull(),

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

                    'message' => $importer->stringType(255),

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

                        $blocks = vtlib\Block::getAllForModule(vtlib\Module::getInstance($field[1]));

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

                        ->set('label', 'FL_WAPRO_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

            ['wapro_id', 'FInvoice', 'LBL_CUSTOM_INFORMATION'],

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

            ['wapro_id', 'FCorectingInvoice', 'LBL_CUSTOM_INFORMATION'],

    Line exceeds 120 characters; contains 162 characters
    Open

                    $check = (new \App\Db\Query())->from('vtiger_field')->where(['tabid' => \App\Module::getModuleId($field[1]), 'fieldname' => $field[0]])->exists();

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

            }

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

                $db->createCommand()->createIndex(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME . '_crmid_idx', \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'crmid', true)->execute();

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

            foreach (self::FIELDS as $field) {

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

                        ->set('columntype', $importer->integer(10)->notNull())

    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 static function check(): bool

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

            if ($check) {

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

                    if (!$check) {

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

            if ($check) {

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

                $db->createTable(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, [

    Line exceeds 120 characters; contains 184 characters
    Open

                $db->createCommand()->createIndex(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME . '_wapro_idx', \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'wtable,wid')->execute();

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

                    $fieldInstance = new Vtiger_Field_Model();

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

                        ->set('column', 'wid')

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

                        $status = false;

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

            return $status ?? false;

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

            ['wapro_id', 'MultiCompany', 'LBL_SYSTEM_INFORMATION'],

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

                $cron = (new \App\Db\Query())->from('vtiger_cron_task')->where(['name' => 'LBL_INTEGRATION_WAPRO', 'handler_class' => 'Vtiger_IntegrationWapro_Cron'])->one();

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

            if (!$db->isTableExists(\App\Integrations\Wapro::LOG_TABLE_NAME)) {

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

                $status = true;

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

                if (!$check) {

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

                        ->set('uitype', 1)

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

                        $status = 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

         * Activate integration in cron.

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

         */

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

                )->execute();

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

                    'category' => $importer->stringType(100),

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

                        $blockModel = current($blocks);

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

                    if ($fieldInstance->save($blockModel)) {

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

        /** @var array Map relation table name */

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

         * @return bool

    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 static function activate(): bool

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

                    if (!$blockModel) {

    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 void

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

            $cron = (new \App\Db\Query())->from('vtiger_cron_task')->where(['name' => 'LBL_INTEGRATION_WAPRO', 'handler_class' => 'Vtiger_IntegrationWapro_Cron'])->one();

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

            }

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

                    $fieldInstance->set('name', $field[0])

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

            self::activateCron();

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

         */

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

            $inventory = Vtiger_Inventory_Model::getInstance('FInvoice');

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

                \App\Cron::updateStatus(\App\Cron::STATUS_ENABLED, 'LBL_INTEGRATION_WAPRO');

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

        private const 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

                    'error' => $importer->boolean(),

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

                $check = (new \App\Db\Query())->from('vtiger_field')->where(['tabid' => $moduleId, 'fieldname' => $field[0]])->exists();

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

                        ->set('tabid', $moduleId)

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

            self::activateInventory();

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

                $check = Vtiger_Inventory_Model::getInstance('FInvoice')->isField('discount_aggreg');

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

        /**

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

                $db->createCommand()->createIndex(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME . '_wapro_idx', \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'wtable,wid')->execute();

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

         * @return void

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

        private static function activateCron(): void

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

        {

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

                \vtlib\Cron::register('LBL_INTEGRATION_WAPRO', 'Vtiger_IntegrationWapro_Cron', 900, 'Vtiger', 1);

    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

        private static function activateInventory(): void

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

            $inventory->saveField($fieldModel);

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

            ['wapro_id', 'Accounts', 'LBL_ADVANCED_BLOCK'],

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

            ['wapro_id', 'Products', 'LBL_PRODUCT_INFORMATION'],

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

            $db = \App\Db::getInstance();

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

            if (!$db->isTableExists(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME)) {

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

                    'crmid' => $importer->integer(10)->notNull(),

    Line exceeds 120 characters; contains 183 characters
    Open

                    'fk_1_' . \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'

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

                    'trace' => $importer->text(),

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

            }

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

                        ->set('displaytype', 9)

    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

         * Check if the functionality has been activated.

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

            $check = $db->isTableExists(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME) && $db->isTableExists(\App\Integrations\Wapro::LOG_TABLE_NAME);

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

                    'wtable' => $importer->stringType('50')->notNull(),

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

            $fieldModel = $inventory->getFieldCleanInstance('DiscountAggregation');

    Line exceeds 120 characters; contains 166 characters
    Open

            $cron = (new \App\Db\Query())->from('vtiger_cron_task')->where(['name' => 'LBL_INTEGRATION_WAPRO', 'handler_class' => 'Vtiger_IntegrationWapro_Cron'])->one();

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

                        break;

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

            if ($check) {

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

                    'wid' => $importer->integer(10)->notNull(),

    Line exceeds 120 characters; contains 185 characters
    Open

                $db->createCommand()->createIndex(\App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME . '_crmid_idx', \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'crmid', true)->execute();

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

                    'fk_1_' . \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, \App\Integrations\Wapro::RECORDS_MAP_TABLE_NAME, 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT'

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

                $status = true;

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

                $moduleId = \App\Module::getModuleId($field[1]);

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

                    $blockModel = vtlib\Block::getInstance($field[2], $field[1]);

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

                        ->set('typeofdata', 'I~O');

    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 "Settings_Wapro_Activation_Model" is not in camel caps format
    Open

    class Settings_Wapro_Activation_Model

    There are no issues that match your filters.

    Category
    Status