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
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]);
- Read upRead up
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]);
Avoid using static access to class '\App\Log' in method 'getDataFromApi'. Open
\App\Log::warning($e->getMessage(), 'RecordCollectors');
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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'];
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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'];
}
- Read upRead up
- Exclude checks
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());
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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());
- Read upRead up
- Exclude checks
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]]);
- Read upRead up
- Exclude checks
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';
- Exclude checks
Similar blocks of code found in 5 locations. Consider refactoring. Open
'Leads' => [
'title' => 'company',
'transliteratedTitle' => 'company',
'registration_number' => 'registration_number_1',
'identifier' => 'vat_id',
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
'Vendors' => [
'title' => 'vendorname',
'transliteratedTitle' => 'vendorname',
'registration_number' => 'registration_number_1',
'identifier' => 'vat_id',
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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',
- Read upRead up
- Exclude checks
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',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'address' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'city' => 'addresslevel5a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedTitle' => 'vendorname',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'identifier' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'email_address' => 'email',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'title' => 'subject',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $displayType = 'FillFields';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'identifier' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'title' => 'company',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedRegion' => 'addresslevel2a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tax_id_number' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => 'addresslevel1a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedSector' => 'siccode',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'address' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $icon = 'yfi-vatify-eu';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedAddress' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'city' => 'addresslevel5a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'fax_number' => 'fax',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedTitle' => 'accountname',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedCity' => 'addresslevel5a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'region' => 'addresslevel2a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'phone_number' => 'phone',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'region' => 'addresslevel2a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'labelModule' => '_Base',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sector' => 'siccode',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Leads' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'registration_number' => 'registration_number_1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tax_id_number' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'postal_code' => 'addresslevel7a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'email_address' => 'email',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedAddress' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'city' => 'addresslevel5a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'community' => 'addresslevel4a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'city' => 'addresslevel5a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected string $addOnName = 'YetiForceRcVatifyEu';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'phone_number' => 'phone',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'community' => 'addresslevel4a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'label' => 'Country',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'picklistModule' => 'Other.Country',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $formFieldsToRecordMap = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'registration_number' => 'registration_number_1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'fax_number' => 'fax',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'postal_code' => 'addresslevel7a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'region' => 'addresslevel2a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => 'addresslevel1a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'community' => 'addresslevel4a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'phone_number' => 'phone',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Partners' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'region' => 'addresslevel2a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'community' => 'addresslevel4a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'region' => 'addresslevel2a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tax_id_number' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedAddress' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'postal_code' => 'addresslevel7a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedCity' => 'addresslevel5a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedAddress' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'city' => 'addresslevel5a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Competition' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $label = 'LBL_VATIFY_EU';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'access_key' => ['required' => 1, 'purifyType' => 'Text', 'label' => 'LBL_ACCESS_KEY'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedTitle' => 'company',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => 'addresslevel1a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedRegion' => 'addresslevel2a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedRegion' => 'addresslevel2a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $fields = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'typeofdata' => 'V~M',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedSector' => 'siccode',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'identifier' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedCity' => 'addresslevel5a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedAddress' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'email_address' => 'email',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $allowedModules = ['Accounts', 'Leads', 'Vendors', 'Partners', 'Competition'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $description = 'LBL_VATIFY_DESC_EU';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'title' => 'accountname',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedCity' => 'addresslevel5a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'community' => 'addresslevel4a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedCity' => 'addresslevel5a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'client_id' => ['required' => 1, 'purifyType' => 'Text', 'label' => 'LBL_CLIENT_ID'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Accounts' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'address' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => 'addresslevel1a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'address' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'identifier' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'address' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'postal_code' => 'addresslevel7a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'identifier' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => 'addresslevel1a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tax_id_number' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'email_address' => 'email1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedTitle' => 'subject',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'email_address' => 'email',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedTitle' => 'subject',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tax_id_number' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'postal_code' => 'addresslevel7a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'uitype' => 16,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $docUrl = 'https://www.vatify.eu/docs/api/getting-started/';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $settingsFields = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Vendors' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'title' => 'vendorname',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'registration_number' => 'registration_number_1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedSector' => 'siccode',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'transliteratedRegion' => 'addresslevel2a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'title' => 'subject',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'AL' => 'Albania',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BA' => 'Bosnia And Herzegovina',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'SK' => 'Slovenia',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => 'addresslevel1a'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Bearer Token. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function search(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = $client->get($link);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'IL' => 'Israel',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LV' => 'Latvia',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'MD' => 'Moldova, Republic Of',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Vendors' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (202 === $response->getStatusCode() || 'FINISHED' !== $body['query']['status']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FI' => 'Finland',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'GB' => 'Northern Ireland',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LT' => 'Lithuania',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'SE' => 'Sweden',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $accessKey;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $bearerToken;
- Exclude checks
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']));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->loadData();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = $client->post($this->url . 'query', ['json' => $params]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::warning($e->getMessage(), 'RecordCollectors');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
usleep($delay);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'RO' => 'Romania',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Competition' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isActive(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$delay = $counter = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'EE' => 'Estonia',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ZA' => 'South Africa',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'labelModule' => '_Base',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'typeofdata' => 'V~M',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => 'addresslevel1a'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vatNumber' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => $country,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->parseData();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\GuzzleHttp\Exception\GuzzleException $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BE' => 'Belgium',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'CZ' => 'Czech Republic',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'HU' => 'Hungary',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vatNumber' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => 'addresslevel1a'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'country' => 'addresslevel1a'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->isActive() || empty($country) || empty($vatNumber)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'identifier' => $vatNumber,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function fetching company data by VAT ID and Country.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getDataFromApi(array $params): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while (!$response && $counter < 5) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$body = \App\Json::decode($response->getBody()->getContents());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->data = $body['result']['items'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'GB' => 'United Kingdom',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'IE' => 'Ireland',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LI' => 'Liechtenstein',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'NO' => 'Norway',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->loadCredentials();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($delay < 10000000) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'AT' => 'Austria',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'PT' => 'Portugal',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Accounts' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vatNumber' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $clientId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'picklistValues' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BG' => 'Bulgaria',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'HR' => 'Croatia',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'IT' => 'Italy',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LU' => 'Luxembourg',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'NL' => 'Netherlands',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vatNumber' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'label' => 'Vat ID',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::warning($e->getMessage(), 'RecordCollectors');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'GE' => 'Georgia',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'IS' => 'Iceland',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Kosovo' => 'Kosovo',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'MT' => 'Malta',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $url = 'https://api.vatify.eu/v1/';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$vatNumber = str_replace([' ', ',', '.', '-'], '', $this->request->getByType('vatNumber', 'Text'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->getBearerToken();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->response;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $params
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->response['error'] = $e->getResponse()->getReasonPhrase();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$delay += 500000;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$counter;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BY' => 'Belarus',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'UA' => 'Ukraine',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $modulesFieldsMap = [
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
return parent::isActive() && ($params = $this->getParams()) && !empty($params['access_key'] && !empty($params['client_id']));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$country = $this->request->getByType('country', 'Text');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'DE' => 'Germany',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'PL' => 'Poland',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'RU' => 'Russian Federation',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Leads' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vatNumber' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Client ID. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'CY' => 'Cyprus',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FR' => 'France',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$link = $response->getHeaderLine('location');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\GuzzleHttp\Exception\GuzzleException $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'DK' => 'Denmark',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ES' => 'Spain',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'KZ' => 'Kazakstan',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ME' => 'Montenegro',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'RS' => 'Serbia',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'CH' => 'Switzerland',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Access Key. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->response['error'] = $e->getResponse()->getReasonPhrase();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'GR' => 'Greece',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'MK' => 'Macedonia, The Former Yugoslav Republic Of',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->getDataFromApi([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$client = \App\RequestHttp::getClient(['headers' => ['Authorization' => 'Bearer ' . $this->bearerToken]]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($link)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = \App\RequestHttp::getClient()->post($this->url . 'oauth2/token', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->bearerToken = $response['access_token'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (($params = $this->getParams()) && !empty($params['client_id'] && !empty($params['access_key']))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getBearerToken(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function parsing data to fields from API.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($this->bearerToken)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->data as $key => $data) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->data[$key] = \App\Utils::flattenKeys($data['data'], 'ucfirst');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
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');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\GuzzleHttp\RequestOptions::JSON => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($this->data)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function fetching Bearer Token.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\GuzzleHttp\Exception\GuzzleException $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function loadCredentials(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function parseData(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->clientId = $params['client_id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Authorization' => 'Basic ' . base64_encode($this->clientId . ':' . $this->accessKey)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'headers' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'grant_type' => 'client_credentials'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function setup Api Key.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::warning($e->getMessage(), 'RecordCollectors');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->accessKey = $params['access_key'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = \App\Json::decode($response->getBody()->getContents());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->response['error'] = $e->getResponse()->getReasonPhrase();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks