YetiForceCompany/YetiForceCRM

View on GitHub
app/RecordCollectors/VatifyEu.php

Summary

Maintainability
B
6 hrs
Test Coverage
F
0%

File VatifyEu.php has 290 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Vatify API file.
 *
 * @see https://www.vatify.eu/coverage.html
Severity: Minor
Found in app/RecordCollectors/VatifyEu.php - About 2 hrs to fix

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

        private function getDataFromApi(array $params): void
        {
            try {
                $client = \App\RequestHttp::getClient(['headers' => ['Authorization' => 'Bearer ' . $this->bearerToken]]);
                $response = $client->post($this->url . 'query', ['json' => $params]);
    Severity: Minor
    Found in app/RecordCollectors/VatifyEu.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 getDataFromApi has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getDataFromApi(array $params): void
        {
            try {
                $client = \App\RequestHttp::getClient(['headers' => ['Authorization' => 'Bearer ' . $this->bearerToken]]);
                $response = $client->post($this->url . 'query', ['json' => $params]);
    Severity: Minor
    Found in app/RecordCollectors/VatifyEu.php - About 1 hr to fix

      Avoid using static access to class '\App\Log' in method 'getDataFromApi'.
      Open

                  \App\Log::warning($e->getMessage(), 'RecordCollectors');
      Severity: Minor
      Found in app/RecordCollectors/VatifyEu.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\Log' in method 'getDataFromApi'.
      Open

                      \App\Log::warning($e->getMessage(), 'RecordCollectors');
      Severity: Minor
      Found in app/RecordCollectors/VatifyEu.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\Utils' in method 'parseData'.
      Open

                  $this->data[$key] = \App\Utils::flattenKeys($data['data'], 'ucfirst');
      Severity: Minor
      Found in app/RecordCollectors/VatifyEu.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 assigning values to variables in if clauses and the like (line '334', column '8').
      Open

          private function loadCredentials(): void
          {
              if (($params = $this->getParams()) && !empty($params['client_id'] && !empty($params['access_key']))) {
                  $this->clientId = $params['client_id'];
                  $this->accessKey = $params['access_key'];
      Severity: Minor
      Found in app/RecordCollectors/VatifyEu.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

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

      Avoid using static access to class '\App\Language' in method 'getBearerToken'.
      Open

                  $this->response['error'] = \App\Language::translate('LBL_VATIFY_EU_NO_AUTH', 'Other.RecordCollector');
      Severity: Minor
      Found in app/RecordCollectors/VatifyEu.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 getDataFromApi uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                      } else {
                          $this->data = $body['result']['items'];
                      }
      Severity: Minor
      Found in app/RecordCollectors/VatifyEu.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\Json' in method 'getBearerToken'.
      Open

                  $response = \App\Json::decode($response->getBody()->getContents());
      Severity: Minor
      Found in app/RecordCollectors/VatifyEu.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\Log' in method 'getBearerToken'.
      Open

                  \App\Log::warning($e->getMessage(), 'RecordCollectors');
      Severity: Minor
      Found in app/RecordCollectors/VatifyEu.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\Json' in method 'getDataFromApi'.
      Open

                      $body = \App\Json::decode($response->getBody()->getContents());
      Severity: Minor
      Found in app/RecordCollectors/VatifyEu.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\RequestHttp' in method 'getDataFromApi'.
      Open

                  $client = \App\RequestHttp::getClient(['headers' => ['Authorization' => 'Bearer ' . $this->bearerToken]]);
      Severity: Minor
      Found in app/RecordCollectors/VatifyEu.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

      syntax error, unexpected 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
      Open

          protected string $addOnName = 'YetiForceRcVatifyEu';
      Severity: Critical
      Found in app/RecordCollectors/VatifyEu.php by phan

      Similar blocks of code found in 5 locations. Consider refactoring.
      Open

              'Leads' => [
                  'title' => 'company',
                  'transliteratedTitle' => 'company',
                  'registration_number' => 'registration_number_1',
                  'identifier' => 'vat_id',
      Severity: Major
      Found in app/RecordCollectors/VatifyEu.php and 4 other locations - About 30 mins to fix
      app/RecordCollectors/Gus.php on lines 44..62
      app/RecordCollectors/Gus.php on lines 63..81
      app/RecordCollectors/UkCompaniesHouse.php on lines 56..74
      app/RecordCollectors/VatifyEu.php on lines 90..108

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 91.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 5 locations. Consider refactoring.
      Open

              'Vendors' => [
                  'title' => 'vendorname',
                  'transliteratedTitle' => 'vendorname',
                  'registration_number' => 'registration_number_1',
                  'identifier' => 'vat_id',
      Severity: Major
      Found in app/RecordCollectors/VatifyEu.php and 4 other locations - About 30 mins to fix
      app/RecordCollectors/Gus.php on lines 44..62
      app/RecordCollectors/Gus.php on lines 63..81
      app/RecordCollectors/UkCompaniesHouse.php on lines 56..74
      app/RecordCollectors/VatifyEu.php on lines 71..89

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 91.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

          public $formFieldsToRecordMap = [
              'Accounts' => [
                  'title' => 'accountname',
                  'transliteratedTitle' => 'accountname',
                  'registration_number' => 'registration_number_1',
      Severity: Minor
      Found in app/RecordCollectors/VatifyEu.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

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

                  'transliteratedRegion' => 'addresslevel2a',

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

                  'address' => 'addresslevel8a',

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

                  'city' => 'addresslevel5a',

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

                  'transliteratedTitle' => 'vendorname',

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

                  'identifier' => 'vat_id',

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

                  'email_address' => 'email',

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

                  'title' => 'subject',

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

          public $displayType = 'FillFields';

      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

                  'identifier' => 'vat_id',

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

                  'title' => 'company',

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

                  'transliteratedRegion' => 'addresslevel2a',

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

                  'tax_id_number' => 'vat_id',

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

                  'country' => 'addresslevel1a',

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

                  'transliteratedSector' => 'siccode',

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

                  'address' => 'addresslevel8a',

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

          public $icon = 'yfi-vatify-eu';

      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

                  'transliteratedAddress' => 'addresslevel8a',

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

                  'city' => 'addresslevel5a',

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

                  'fax_number' => 'fax',

      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

                  'transliteratedTitle' => 'accountname',

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

                  'transliteratedCity' => 'addresslevel5a',

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

                  'region' => 'addresslevel2a',

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

                  'phone_number' => 'phone',

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

                  'region' => 'addresslevel2a',

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

                  'labelModule' => '_Base',

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

                  'sector' => 'siccode',

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

              'Leads' => [

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

                  'registration_number' => 'registration_number_1',

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

                  'tax_id_number' => 'vat_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

          /** {@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

                  'postal_code' => 'addresslevel7a',

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

                  'email_address' => 'email',

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

                  'transliteratedAddress' => 'addresslevel8a',

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

                  'city' => 'addresslevel5a',

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

                  'community' => 'addresslevel4a',

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

                  'city' => 'addresslevel5a',

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

          protected string $addOnName = 'YetiForceRcVatifyEu';

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

                  'phone_number' => 'phone',

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

                  'community' => 'addresslevel4a',

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

              ],

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

                  'label' => 'Country',

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

                  'picklistModule' => 'Other.Country',

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

          public $formFieldsToRecordMap = [

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

                  'registration_number' => 'registration_number_1',

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

                  'fax_number' => 'fax',

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

                  'postal_code' => 'addresslevel7a',

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

                  'region' => 'addresslevel2a',

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

                  'country' => 'addresslevel1a',

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

                  'community' => 'addresslevel4a',

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

              'country' => [

      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

                  'phone_number' => 'phone',

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

              'Partners' => [

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

                  'region' => 'addresslevel2a',

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

                  'community' => 'addresslevel4a',

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

                  'region' => 'addresslevel2a',

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

                  'tax_id_number' => 'vat_id',

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

                  'transliteratedAddress' => 'addresslevel8a',

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

                  'postal_code' => 'addresslevel7a',

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

                  'transliteratedCity' => 'addresslevel5a',

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

                  'transliteratedAddress' => 'addresslevel8a',

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

                  'city' => 'addresslevel5a',

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

              'Competition' => [

      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

          public $label = 'LBL_VATIFY_EU';

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

              'access_key' => ['required' => 1, 'purifyType' => 'Text', 'label' => 'LBL_ACCESS_KEY'],

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

              ],

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

                  'transliteratedTitle' => 'company',

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

                  'country' => 'addresslevel1a',

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

                  'transliteratedRegion' => 'addresslevel2a',

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

                  'transliteratedRegion' => 'addresslevel2a',

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

          protected $fields = [

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

                  'typeofdata' => 'V~M',

      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

                  'transliteratedSector' => 'siccode',

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

                  'identifier' => 'vat_id',

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

                  'transliteratedCity' => 'addresslevel5a',

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

                  'transliteratedAddress' => 'addresslevel8a',

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

                  'email_address' => 'email',

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

          public $allowedModules = ['Accounts', 'Leads', 'Vendors', 'Partners', 'Competition'];

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

          public $description = 'LBL_VATIFY_DESC_EU';

      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

                  'title' => 'accountname',

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

                  'transliteratedCity' => 'addresslevel5a',

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

                  'community' => 'addresslevel4a',

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

                  'transliteratedCity' => 'addresslevel5a',

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

              'client_id' => ['required' => 1, 'purifyType' => 'Text', 'label' => 'LBL_CLIENT_ID'],

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

              'Accounts' => [

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

                  'address' => 'addresslevel8a',

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

                  'country' => 'addresslevel1a',

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

                  'address' => 'addresslevel8a',

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

                  'identifier' => 'vat_id',

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

                  'address' => 'addresslevel8a',

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

                  'postal_code' => 'addresslevel7a',

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

                  'identifier' => 'vat_id',

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

                  'country' => 'addresslevel1a',

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

              ],

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

                  'tax_id_number' => 'vat_id',

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

                  'email_address' => 'email1',

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

              ],

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

                  'transliteratedTitle' => 'subject',

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

                  'email_address' => 'email',

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

                  'transliteratedTitle' => 'subject',

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

                  'tax_id_number' => 'vat_id',

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

                  'postal_code' => 'addresslevel7a',

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

                  'uitype' => 16,

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

          public $docUrl = 'https://www.vatify.eu/docs/api/getting-started/';

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

          public $settingsFields = [

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

              'Vendors' => [

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

                  'title' => 'vendorname',

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

                  'registration_number' => 'registration_number_1',

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

                  'transliteratedSector' => 'siccode',

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

                  'transliteratedRegion' => 'addresslevel2a',

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

                  'title' => 'subject',

      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

                      'AL' => 'Albania',

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

                      'BA' => 'Bosnia And Herzegovina',

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

                      'SK' => 'Slovenia',

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

              ],

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

                  'country' => 'addresslevel1a'

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

          /** @var string Bearer Token. */

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

          public function search(): 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

                      $response = $client->get($link);

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

                      'IL' => 'Israel',

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

                      'LV' => 'Latvia',

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

                      'MD' => 'Moldova, Republic Of',

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

              'Vendors' => [

      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 (202 === $response->getStatusCode() || 'FINISHED' !== $body['query']['status']) {

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

                      'FI' => 'Finland',

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

                      'GB' => 'Northern Ireland',

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

                      'LT' => 'Lithuania',

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

                      'SE' => 'Sweden',

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

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

          private $bearerToken;

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

              return parent::isActive() && ($params = $this->getParams()) && !empty($params['access_key'] && !empty($params['client_id']));

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

              $this->loadData();

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

                  $response = $client->post($this->url . 'query', ['json' => $params]);

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

                  \App\Log::warning($e->getMessage(), 'RecordCollectors');

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

                  }

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

                  usleep($delay);

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

                      'RO' => 'Romania',

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

              'Competition' => [

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

          public function isActive(): 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

              $delay = $counter = 0;

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

          }

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

                      'EE' => 'Estonia',

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

                      'ZA' => 'South Africa',

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

                  'labelModule' => '_Base',

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

                  'typeofdata' => 'V~M',

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

                  'country' => 'addresslevel1a'

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

                  'vatNumber' => 'vat_id',

      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

                  'country' => $country,

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

              $this->parseData();

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

          {

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

                  } catch (\GuzzleHttp\Exception\GuzzleException $e) {

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

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

              }

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

                      'BE' => 'Belgium',

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

                      'CZ' => 'Czech Republic',

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

                      'HU' => 'Hungary',

      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

                  'vatNumber' => 'vat_id',

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

                  'country' => 'addresslevel1a'

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

                  'country' => 'addresslevel1a'

      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->isActive() || empty($country) || empty($vatNumber)) {

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

                  'identifier' => $vatNumber,

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

           * Function fetching company data by VAT ID and Country.

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

          private function getDataFromApi(array $params): void

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

              $response = null;

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

              while (!$response && $counter < 5) {

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

                      $body = \App\Json::decode($response->getBody()->getContents());

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

                          $this->data = $body['result']['items'];

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

                      'GB' => 'United Kingdom',

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

                      'IE' => 'Ireland',

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

                      'LI' => 'Liechtenstein',

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

                      'NO' => 'Norway',

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

              ],

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

              $this->loadCredentials();

      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

                  if ($delay < 10000000) {

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

                  try {

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

                      'AT' => 'Austria',

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

                      'PT' => 'Portugal',

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

              'Accounts' => [

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

                  'vatNumber' => 'vat_id',

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

          private $clientId;

      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

                  'picklistValues' => [

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

                      'BG' => 'Bulgaria',

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

                      'HR' => 'Croatia',

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

                      'IT' => 'Italy',

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

                      'LU' => 'Luxembourg',

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

                      'NL' => 'Netherlands',

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

              ],

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

              'vatNumber' => [

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

                  'label' => 'Vat 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

          /** {@inheritdoc} */

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

                      \App\Log::warning($e->getMessage(), 'RecordCollectors');

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

                      'GE' => 'Georgia',

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

                      'IS' => 'Iceland',

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

                      'Kosovo' => 'Kosovo',

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

                      'MT' => 'Malta',

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

          private $url = 'https://api.vatify.eu/v1/';

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

              $vatNumber = str_replace([' ', ',', '.', '-'], '', $this->request->getByType('vatNumber', 'Text'));

      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

              $this->getBearerToken();

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

              return $this->response;

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

           * @param array $params

      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

                  $this->response['error'] = $e->getResponse()->getReasonPhrase();

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

                      $delay += 500000;

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

                  ++$counter;

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

                      'BY' => 'Belarus',

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

                      'UA' => 'Ukraine',

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

          protected $modulesFieldsMap = [

      Line exceeds 120 characters; contains 133 characters
      Open

              return parent::isActive() && ($params = $this->getParams()) && !empty($params['access_key'] && !empty($params['client_id']));

      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

              $country = $this->request->getByType('country', 'Text');

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

                      'DE' => 'Germany',

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

                      'PL' => 'Poland',

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

                      'RU' => 'Russian Federation',

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

                  ]

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

              'Leads' => [

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

              ],

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

              try {

      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

                  'vatNumber' => 'vat_id',

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

          /** @var string Client 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

                      'CY' => 'Cyprus',

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

                      'FR' => 'France',

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

                  $link = $response->getHeaderLine('location');

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

              } catch (\GuzzleHttp\Exception\GuzzleException $e) {

      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

                      'DK' => 'Denmark',

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

                      'ES' => 'Spain',

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

                      'KZ' => 'Kazakstan',

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

                      'ME' => 'Montenegro',

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

                      'RS' => 'Serbia',

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

                      'CH' => 'Switzerland',

      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 Access Key. */

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

                          $response = null;

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

                      }

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

                      $this->response['error'] = $e->getResponse()->getReasonPhrase();

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

                      'GR' => 'Greece',

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

                      'MK' => 'Macedonia, The Former Yugoslav Republic Of',

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

          ];

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

              $this->getDataFromApi([

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

          /**

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

                  $client = \App\RequestHttp::getClient(['headers' => ['Authorization' => 'Bearer ' . $this->bearerToken]]);

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

              if (empty($link)) {

      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

                  $response = \App\RequestHttp::getClient()->post($this->url . 'oauth2/token', [

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

                  $this->bearerToken = $response['access_token'];

      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

              if (($params = $this->getParams()) && !empty($params['client_id'] && !empty($params['access_key']))) {

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

          private function getBearerToken(): void

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

           * Function parsing data to fields from API.

      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

              if (empty($this->bearerToken)) {

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

           */

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

              foreach ($this->data as $key => $data) {

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

                  $this->data[$key] = \App\Utils::flattenKeys($data['data'], 'ucfirst');

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

          }

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

                  $this->response['error'] = \App\Language::translate('LBL_VATIFY_EU_NO_AUTH', 'Other.RecordCollector');

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

              try {

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

                      \GuzzleHttp\RequestOptions::JSON => [

      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($this->data)) {

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

           * Function fetching Bearer Token.

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

                      ]

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

              } catch (\GuzzleHttp\Exception\GuzzleException $e) {

      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

          private function loadCredentials(): 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

          private function parseData(): void

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

                  $this->clientId = $params['client_id'];

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

                          'Authorization' => 'Basic ' . base64_encode($this->clientId . ':' . $this->accessKey)

      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

                      'headers' => [

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

                          'grant_type' => 'client_credentials'

      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

           * @return 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

           * Function setup Api Key.

      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

                  \App\Log::warning($e->getMessage(), 'RecordCollectors');

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

          /**

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

                  $this->accessKey = $params['access_key'];

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

                  $response = \App\Json::decode($response->getBody()->getContents());

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

                  $this->response['error'] = $e->getResponse()->getReasonPhrase();

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

          }

      There are no issues that match your filters.

      Category
      Status