YetiForceCompany/YetiForceCRM

View on GitHub
modules/Leads/models/Record.php

Summary

Maintainability
C
1 day
Test Coverage
F
21%

Function getAccountFieldsForLeadConvert has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAccountFieldsForLeadConvert()
    {
        $accountsFields = [];
        $moduleName = 'Accounts';

Severity: Minor
Found in modules/Leads/models/Record.php - About 4 hrs 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 getConvertLeadMappedField has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function getConvertLeadMappedField($fieldName, $moduleName)
    {
        $mappingFields = $this->get('mappingFields');

        if (!$mappingFields) {
Severity: Minor
Found in modules/Leads/models/Record.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

Method getAccountFieldsForLeadConvert has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getAccountFieldsForLeadConvert()
    {
        $accountsFields = [];
        $moduleName = 'Accounts';

Severity: Minor
Found in modules/Leads/models/Record.php - About 1 hr to fix

    Method getConvertLeadMappedField has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getConvertLeadMappedField($fieldName, $moduleName)
        {
            $mappingFields = $this->get('mappingFields');
    
            if (!$mappingFields) {
    Severity: Minor
    Found in modules/Leads/models/Record.php - About 1 hr to fix

      The method getAccountFieldsForLeadConvert() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
      Open

          public function getAccountFieldsForLeadConvert()
          {
              $accountsFields = [];
              $moduleName = 'Accounts';
      
      
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      CyclomaticComplexity

      Since: 0.1

      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

      Example

      // Cyclomatic Complexity = 11
      class Foo {
      1   public function example() {
      2       if ($a == $b) {
      3           if ($a1 == $b1) {
                      fiddle();
      4           } elseif ($a2 == $b2) {
                      fiddle();
                  } else {
                      fiddle();
                  }
      5       } elseif ($c == $d) {
      6           while ($c == $d) {
                      fiddle();
                  }
      7        } elseif ($e == $f) {
      8           for ($n = 0; $n < $h; $n++) {
                      fiddle();
                  }
              } else {
                  switch ($z) {
      9               case 1:
                          fiddle();
                          break;
      10              case 2:
                          fiddle();
                          break;
      11              case 3:
                          fiddle();
                          break;
                      default:
                          fiddle();
                          break;
                  }
              }
          }
      }

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

      Refactor this function to reduce its Cognitive Complexity from 30 to the 15 allowed.
      Open

          public function getAccountFieldsForLeadConvert()
      Severity: Critical
      Found in modules/Leads/models/Record.php by sonar-php

      Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

      See

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

                  $query = (new \App\Db\Query())->from('vtiger_convertleadmapping');
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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 '29', column '29').
      Open

                  $returnVal = (bool) (new \App\Db\Query())->select(['converted'])->from('vtiger_leaddetails')->where(['leadid' => $this->getId()])->scalar();
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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\Cache' in method 'getConverted'.
      Open

              } elseif (\App\Cache::has('Leads.converted', $this->getId())) {
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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\Privilege' in method 'getAccountFieldsForLeadConvert'.
      Open

              if (!\App\Privilege::isPermitted($moduleName, 'EditView')) {
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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_Module_Model' in method 'getAccountFieldsForLeadConvert'.
      Open

              $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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\Cache' in method 'save'.
      Open

                  \App\Cache::delete('Leads.converted', $this->getId());
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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_Field_Model' in method 'getAccountFieldsForLeadConvert'.
      Open

                      $fieldModel = Vtiger_Field_Model::getInstance($complusoryField, $moduleModel);
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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_Module_Model' in method 'getConvertLeadMappedField'.
      Open

                  $accountInstance = Vtiger_Module_Model::getInstance('Accounts');
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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\Cache' in method 'delete'.
      Open

              \App\Cache::delete('Leads.converted', $this->getId());
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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_Module_Model' in method 'getConvertLeadMappedField'.
      Open

                  $leadInstance = Vtiger_Module_Model::getInstance('Leads');
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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 getConverted uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $returnVal = (bool) (new \App\Db\Query())->select(['converted'])->from('vtiger_leaddetails')->where(['leadid' => $this->getId()])->scalar();
                  \App\Cache::save('Leads.converted', $this->getId(), $returnVal);
              }
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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

      Avoid using static access to class '\App\Cache' in method 'getConverted'.
      Open

                  \App\Cache::save('Leads.converted', $this->getId(), $returnVal);
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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 getAccountFieldsForLeadConvert uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                          } else {
                              $industryFieldModel->set('fieldvalue', $fieldModel->getDefaultFieldValue());
                          }
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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

      Avoid using static access to class '\App\Cache' in method 'getConverted'.
      Open

                  $returnVal = (bool) \App\Cache::get('Leads.converted', $this->getId());
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

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

                      if ($row['accountfid'] && isset($accountFieldInstances[$row['accountfid']])) {
      Severity: Critical
      Found in modules/Leads/models/Record.php by sonar-php

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

                              $fieldModel->set('fieldvalue', $this->get($leadMappedField));
      Severity: Critical
      Found in modules/Leads/models/Record.php by sonar-php

      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 "Leads.converted" 5 times.
      Open

              } elseif (\App\Cache::has('Leads.converted', $this->getId())) {
      Severity: Critical
      Found in modules/Leads/models/Record.php by sonar-php

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

              $moduleName = 'Accounts';
      Severity: Critical
      Found in modules/Leads/models/Record.php by sonar-php

      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 undeclared method \App\Db\Query::select
      Open

                  $returnVal = (bool) (new \App\Db\Query())->select(['converted'])->from('vtiger_leaddetails')->where(['leadid' => $this->getId()])->scalar();
      Severity: Critical
      Found in modules/Leads/models/Record.php by phan

      Argument 2 (key) is int but \App\Cache::delete() takes string defined at /code/app/Cache.php:105
      Open

                  \App\Cache::delete('Leads.converted', $this->getId());
      Severity: Minor
      Found in modules/Leads/models/Record.php by phan

      Argument 2 (key) is int but \App\Cache::delete() takes string defined at /code/app/Cache.php:105
      Open

              \App\Cache::delete('Leads.converted', $this->getId());
      Severity: Minor
      Found in modules/Leads/models/Record.php by phan

      Returning type void but getAccountFieldsForLeadConvert() is declared to return array
      Open

                  return;
      Severity: Minor
      Found in modules/Leads/models/Record.php by phan

      Argument 2 (key) is int but \App\Cache::has() takes string defined at /code/app/Cache.php:74
      Open

              } elseif (\App\Cache::has('Leads.converted', $this->getId())) {
      Severity: Minor
      Found in modules/Leads/models/Record.php by phan

      Argument 2 (key) is int but \App\Cache::save() takes string defined at /code/app/Cache.php:89
      Open

                  \App\Cache::save('Leads.converted', $this->getId(), $returnVal);
      Severity: Minor
      Found in modules/Leads/models/Record.php by phan

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

                  $query = (new \App\Db\Query())->from('vtiger_convertleadmapping');
      Severity: Critical
      Found in modules/Leads/models/Record.php by phan

      Argument 2 (key) is int but \App\Cache::get() takes string defined at /code/app/Cache.php:61
      Open

                  $returnVal = (bool) \App\Cache::get('Leads.converted', $this->getId());
      Severity: Minor
      Found in modules/Leads/models/Record.php by phan

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

                  $accountFieldInstances = $accountInstance->getFieldsById();
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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

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

                          $industryLeadMappedField = $this->getConvertLeadMappedField($complusoryField, $moduleName);
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      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 Leads_Record_Model extends Vtiger_Record_Model

      The class Leads_Record_Model is not named in CamelCase.
      Open

      class Leads_Record_Model extends Vtiger_Record_Model
      {
          /**
           * Get converted column.
           *
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      CamelCaseClassName

      Since: 0.2

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

      Example

      class class_name {
      }

      Source

      The 'getConverted()' method which returns a boolean should be named 'is...()' or 'has...()'
      Open

          public function getConverted(): bool
          {
              if ($this->isNew()) {
                  $returnVal = false;
              } elseif (\App\Cache::has('Leads.converted', $this->getId())) {
      Severity: Minor
      Found in modules/Leads/models/Record.php by phpmd

      BooleanGetMethodName

      Since: 0.2

      Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

      Example

      class Foo {
          /**
           * @return boolean
           */
          public function getFoo() {} // bad
          /**
           * @return bool
           */
          public function isFoo(); // ok
          /**
           * @return boolean
           */
          public function getFoo($bar); // ok, unless checkParameterizedMethods=true
      }

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

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

          public function getConverted(): bool

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

              return $returnVal;

      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 parent::isEditable() && !$this->getConverted();

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

           */

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

                  $complusoryFields = []; //Field List in the conversion lead

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

                  foreach ($fieldModels as $fieldName => $fieldModel) {

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

                          if (false !== $keyIndex) {

      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 $accountsFields;

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

          public function getAccountFieldsForLeadConvert()

      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

              } else {

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

           * @return array

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

              if (!\App\Privilege::isPermitted($moduleName, 'EditView')) {

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

                          }

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

              parent::save();

      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 isPermitted(string $action)

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

           * Function returns Account fields for Lead Convert.

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

              $accountsFields = [];

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

                  while ($row = $dataReader->read()) {

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

                      $leadFieldName = $leadFieldInstance->getName();

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

                      if ($row['accountfid'] && isset($accountFieldInstances[$row['accountfid']])) {

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

           * Function returns the fields required for Lead Convert.

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

           */

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

              $convertFields = [];

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

                  \App\Cache::save('Leads.converted', $this->getId(), $returnVal);

      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 parent::isViewable() && !$this->getConverted();

      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

              return parent::isPermitted($action) && !$this->getConverted();

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

                  //Fields that need to be shown

      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

      Line exceeds 120 characters; contains 152 characters
      Open

                  $returnVal = (bool) (new \App\Db\Query())->select(['converted'])->from('vtiger_leaddetails')->where(['leadid' => $this->getId()])->scalar();

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

           * @return string

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

                  $returnVal = false;

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

                          }

      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

          }

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

           */

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

              if (!$mappingFields) {

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

                          $accountsFields[] = $fieldModel;

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

                      if (!$leadFieldInstance) {

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

                      $fieldModel = Vtiger_Field_Model::getInstance($complusoryField, $moduleModel);

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

                  $accountInstance = Vtiger_Module_Model::getInstance('Accounts');

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

                          continue;

      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

           * Get converted column.

      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

              $moduleModel = Vtiger_Module_Model::getInstance($moduleName);

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

                          $industryFieldModel = $moduleModel->getField($complusoryField);

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

                  $query = (new \App\Db\Query())->from('vtiger_convertleadmapping');

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

                  $this->set('mappingFields', $mappingFields);

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

           *

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

                  $accountFieldInstances = $accountInstance->getFieldsById();

      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 function delete()

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

          }

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

              $moduleName = 'Accounts';

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

              if ($moduleModel->isActive()) {

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

                          if ($leadMappedField) {

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

                          if ($industryLeadMappedField) {

      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 function getConvertLeadMappedField($fieldName, $moduleName)

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

                  $leadInstance = Vtiger_Module_Model::getInstance('Leads');

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

              $accountFields = $this->getAccountFieldsForLeadConvert();

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

                      }

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

                          $mappingFields['Accounts'][$accountFieldInstances[$row['accountfid']]->getName()] = $leadFieldName;

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

          {

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

              if ($this->isNew()) {

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

          public function save()

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

          public function isViewable()

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

          public function isEditable(): bool

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

              return 'index.php?module=' . $this->getModuleName() . '&view=ConvertLead&record=' . $this->getId();

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

           *

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

                              unset($complusoryFields[$keyIndex]);

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

                              $fieldModel->set('fieldvalue', $this->get($leadMappedField));

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

                          $industryLeadMappedField = $this->getConvertLeadMappedField($complusoryField, $moduleName);

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

                              $industryFieldModel->set('fieldvalue', $fieldModel->getDefaultFieldValue());

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

                      }

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

           * Function returns field mapped to Leads field, used in Lead Convert for settings the field values.

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

              return $convertFields;

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

              }

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

              if (!$this->isNew()) {

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

          }

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

           * Function returns the url for converting lead.

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

                          if ('' == $fieldModel->get('fieldvalue')) {

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

                              $industryFieldModel->set('fieldvalue', $this->get($industryLeadMappedField));

      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

                          continue;

      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

                  $leadFieldInstances = $leadInstance->getFieldsById();

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

                  $dataReader = $query->createCommand()->query();

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

          public function getConvertLeadFields()

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

                  $mappingFields = [];

      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

                  return;

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

                          $keyIndex = array_search($fieldName, $complusoryFields);

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

                  foreach ($complusoryFields as $complusoryField) {

      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

                      }

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

              $mappingFields = $this->get('mappingFields');

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

                      $leadFieldInstance = $leadFieldInstances[$row['leadfid']];

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

              return $mappingFields[$moduleName][$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

              } elseif (\App\Cache::has('Leads.converted', $this->getId())) {

      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

              \App\Cache::delete('Leads.converted', $this->getId());

      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

                      if ($fieldModel->isMandatory() && 'assigned_user_id' != $fieldName) {

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

                          $leadMappedField = $this->getConvertLeadMappedField($fieldName, $moduleName);

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

                      if ($fieldModel->getPermissions(false)) {

      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

           * @return string

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

                  $dataReader->close();

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

           * @return Vtiger_Field_Model[]

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

              if (!empty($accountFields)) {

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

              }

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

                  $returnVal = (bool) \App\Cache::get('Leads.converted', $this->getId());

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

                  $returnVal = (bool) (new \App\Db\Query())->select(['converted'])->from('vtiger_leaddetails')->where(['leadid' => $this->getId()])->scalar();

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

          }

      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

                  \App\Cache::delete('Leads.converted', $this->getId());

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

              parent::delete();

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

          public function getConvertLeadUrl()

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

          }

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

                  $fieldModels = $moduleModel->getFields();

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

                              $fieldModel->set('fieldvalue', $fieldModel->getDefaultFieldValue());

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

                          $accountsFields[] = $industryFieldModel;

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

           * @param string $moduleName

      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

                      if (empty($row['leadfid'])) {

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

          }

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

                  $convertFields['Accounts'] = $accountFields;

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

      class Leads_Record_Model extends Vtiger_Record_Model

      There are no issues that match your filters.

      Category
      Status