Function search
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function search(): array
{
if (!$this->isActive()) {
return [];
}
- 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
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\Json' in method 'getDataFromApi'. Open
$data = isset($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\Utils' in method 'parseData'. Open
return \App\Utils::flattenKeys($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
syntax error, unexpected 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Open
protected string $addOnName = 'YetiForceRcFrEnterpriseGouv';
- Exclude checks
Avoid excessively long variable names like $formFieldsToRecordMap. Keep variable name length under 20. Open
public $formFieldsToRecordMap = [
'Accounts' => [
'nom_complet' => 'accountname',
'siren' => 'vat_id',
'siegeActivite_principale' => 'siccode',
- 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
const LIMIT = 4;
- 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 $icon = 'yfi-entreprise-gouv-fr';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var int Number of items returned */
- 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
'siegeSiret' => 'registration_number_1',
- 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
'siegeAdresse_complete_secondaire' => 'buildingnumbera',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'nom_complet' => 'subject',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'siegeAdresse_complete' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'companyName' => 'accountname',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'companyName' => 'subject',
- 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
}
- 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
return $this->response;
- 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 ($data['results'] as $key => $result) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $description = 'LBL_FR_ENTERPRISE_GOUV_DESC';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'siegeAdresse_complete_secondaire' => 'buildingnumbera',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sicCode' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $modulesFieldsMap = [
- 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
* @return array
- 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
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query['q'] = $vatNumber;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query['q'] = $companyName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query['activite_principale'] = $sicCode;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $data
- 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
'labelModule' => '_Base',
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function fetching company data by params.
- 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
'siren' => 'vat_id',
- 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
'siren' => 'vat_id',
- 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
'vatNumber' => 'vat_id'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Server address */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($vatNumber)) {
- 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
/** {@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
'siegeAdresse_complete_secondaire' => 'buildingnumbera',
- 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
'siren' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'siegeLibelle_commune' => '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
];
- 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
$sicCode = str_replace([' ', ',', '.', '-'], '', $this->request->getByType('sicCode', 'Text'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $query
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($data)) {
- 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
'siegeActivite_principale' => 'siccode',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'siegeLibelle_commune' => '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
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected string $addOnName = 'YetiForceRcFrEnterpriseGouv';
- 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
'companyName' => 'vendorname',
- 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
public function search(): array
- 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 (!empty($sicCode)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->getDataFromApi($query);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getDataFromApi(array $query): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'nom_complet' => 'accountname',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'siren' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'siegeLibelle_commune' => 'addresslevel4a'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'siegeAdresse_complete_secondaire' => 'buildingnumbera',
- 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' => 'VAT',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'companyName' => 'subject',
- 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
public $allowedModules = ['Accounts', 'Leads', 'Vendors', 'Partners', 'Competition'];
- 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
'siegeAdresse_complete' => 'addresslevel8a',
- 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
'companyName' => [
- 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
* @return void
- 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
$this->response['error'] = $e->getMessage();
- 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
'siren' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sicCode' => 'siccode',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = [];
- 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
*
- 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
'siegeSiret' => 'registration_number_1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'siegeAdresse_complete' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'siegeSiret' => 'registration_number_1',
- 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
'vatNumber' => '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
$companyName = $this->request->getByType('companyName', 'Text');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'nom_complet' => 'vendorname',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'siegeAdresse_complete' => 'addresslevel8a',
- 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
'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
if (empty($vatNumber) && empty($sicCode) && empty($companyName)) {
- 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->data[$key] = $this->parseData($result);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $docUrl = 'https://api.gouv.fr/les-api/api-entreprise/';
- 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
],
- 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
return [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query['per_page'] = self::LIMIT;
- 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
'siegeAdresse_complete' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'nom_complet' => 'subject',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'siegeLibelle_commune' => 'addresslevel4a'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'label' => 'SIC code',
- 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
'companyName' => 'company',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $url = 'https://recherche-entreprises.api.gouv.fr/';
- 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
} elseif (!empty($companyName) && empty($vatNumber)) {
- 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
'siegeAdresse_complete_secondaire' => 'buildingnumbera',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'siegeLibelle_commune' => '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
'labelModule' => '_Base',
- 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
'Leads' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->isActive()) {
- 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
public $label = 'LBL_FR_ENTERPRISE_GOUV';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'activite_principale' => 'siccode',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'nom_complet' => 'company',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'label' => 'Account name',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = \App\RequestHttp::getClient()->get($this->url . 'search?' . http_build_query($query));
- 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
$data = isset($response) ? \App\Json::decode($response->getBody()->getContents()) : [];
- 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
return \App\Utils::flattenKeys($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
private function parseData(array $data): array
- Exclude checks