Missing class import via use statement (line '175', column '14'). Open
throw new \App\Exceptions\IllegalValue('You must fist setup Api Key in Config Panel', 403);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class '\App\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 assigning values to variables in if clauses and the like (line '172', column '8'). Open
private function setApiKey(): void
{
if (($params = $this->getParams()) && !empty($params['api_key'])) {
$this->apiKey = $params['api_key'];
} else {
- 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\Json' in method 'getDataFromApi'. Open
$this->data = $this->parseData(\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
The method setApiKey uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new \App\Exceptions\IllegalValue('You must fist setup Api Key in Config Panel', 403);
}
- 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\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 'bool' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Open
protected bool $paid = false;
- Exclude checks
Avoid excessively long variable names like $formFieldsToRecordMap. Keep variable name length under 20. Open
public $formFieldsToRecordMap = [
'Accounts' => [
'name' => 'accountname',
'address' => 'addresslevel8a',
'economicActivityCode' => '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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $description = 'LBL_UA_YOU_CONTROL_DESC';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $docUrl = 'https://youscore.com.ua/en/';
- 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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $icon = 'yfi-you-control';
- 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
/** {@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
public $label = 'LBL_UA_YOU_CONTROL';
- 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 $settingsFields = [
- 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
'companyNumber' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'companyNumber' => 'registration_number_1',
- 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
$this->response['error'] = $e->getResponse()->getReasonPhrase();
- 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 $fields = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $apiKey;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$companyNumber = str_replace([' ', ',', '.', '-'], '', $this->request->getByType('companyNumber', '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
$response = [];
- 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
/**
- 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
'address' => 'addresslevel8a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => 'subject',
- 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
private function parseData(array $data): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function setApiKey(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->apiKey = $params['api_key'];
- 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
'economicActivityDescription' => 'description'
- 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
'name' => 'subject',
- 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 (200 === $response->getStatusCode()) {
- 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
'economicActivityDescription' => 'description'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'economicActivityDescription' => 'description'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'companyNumber' => 'registration_number_1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected bool $paid = false;
- 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
\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
}
- 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
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function parsing data to fields from Companies House API.
- 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
];
- 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
'labelModule' => '_Base',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->isActive() || empty($companyNumber)) {
- 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([
- 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
'Vendors' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return parent::isActive() && ($params = $this->getParams()) && !empty($params['api_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
* Function fetching company data by Company Number from YouScore API.
- 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 array
- 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
if (($params = $this->getParams()) && !empty($params['api_key'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue('You must fist setup Api Key in Config Panel', 403);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $url = 'https://api.youscore.com.ua/v1/companyInfo/';
- 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
return [];
- 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
'api_key' => ['required' => 1, 'purifyType' => 'Text', 'label' => 'LBL_API_KEY'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'economicActivityCode' => '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
'name' => 'company',
- 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
/** {@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
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setApiKey();
- 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
'address' => 'addresslevel8a',
- 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
* @param string $companyNumber
- 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
'label' => 'Registration number 1',
- 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
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Authorization' => 'Bearer ' . $this->apiKey
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->data = $this->parseData(\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
'address' => 'addresslevel8a',
- 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
];
- 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
/** @var string YouScore sever address */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Api Key. */
- 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getDataFromApi(string $companyNumber): void
- 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
}
- 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
'companyNumber' => 'registration_number_1',
- 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
$this->getDataFromApi($companyNumber);
- 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
'name' => 'accountname',
- 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
'economicActivityDescription' => 'description'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'economicActivityDescription' => 'description'
- 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
$this->loadData();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->get($this->url . $companyNumber);
- 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
'name' => 'vendorname',
- 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
'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
];
- 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 function search(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks