YetiForceCompany/YetiForceCRM

View on GitHub
app/RecordCollectors/UaYouControl.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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);
Severity: Minor
Found in app/RecordCollectors/UaYouControl.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

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

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

    private function setApiKey(): void
    {
        if (($params = $this->getParams()) && !empty($params['api_key'])) {
            $this->apiKey = $params['api_key'];
        } else {
Severity: Minor
Found in app/RecordCollectors/UaYouControl.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\Json' in method 'getDataFromApi'.
Open

                $this->data = $this->parseData(\App\Json::decode($response->getBody()->getContents()));
Severity: Minor
Found in app/RecordCollectors/UaYouControl.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 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);
        }
Severity: Minor
Found in app/RecordCollectors/UaYouControl.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\Utils' in method 'parseData'.
Open

        return \App\Utils::flattenKeys($data, 'ucfirst');
Severity: Minor
Found in app/RecordCollectors/UaYouControl.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 'bool' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Open

    protected bool $paid = false;
Severity: Critical
Found in app/RecordCollectors/UaYouControl.php by phan

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

    public $formFieldsToRecordMap = [
        'Accounts' => [
            'name' => 'accountname',
            'address' => 'addresslevel8a',
            'economicActivityCode' => 'siccode',
Severity: Minor
Found in app/RecordCollectors/UaYouControl.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

    /** {@inheritdoc} */

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

    public $description = 'LBL_UA_YOU_CONTROL_DESC';

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

    public $docUrl = 'https://youscore.com.ua/en/';

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

    /** {@inheritdoc} */

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

    public $icon = 'yfi-you-control';

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

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

    public $label = 'LBL_UA_YOU_CONTROL';

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 $settingsFields = [

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

        'companyNumber' => [

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

            'companyNumber' => 'registration_number_1',

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

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

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

        ],

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

    private $apiKey;

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

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

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 = [];

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

    /**

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

            'address' => 'addresslevel8a',

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

            'name' => 'subject',

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

    private function parseData(array $data): array

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

    private function setApiKey(): void

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

            $this->apiKey = $params['api_key'];

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

            'economicActivityDescription' => 'description'

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

        ],

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

            'name' => 'subject',

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 (200 === $response->getStatusCode()) {

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

            'economicActivityDescription' => 'description'

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

            'economicActivityDescription' => 'description'

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

            'companyNumber' => 'registration_number_1',

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

    protected bool $paid = false;

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

    {

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

            \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

     */

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

        'Accounts' => [

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 parsing data to fields from Companies House API.

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

        if (empty($data)) {

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

    public $formFieldsToRecordMap = [

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

        if (!$this->isActive() || empty($companyNumber)) {

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([

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

        'Vendors' => [

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

        return parent::isActive() && ($params = $this->getParams()) && !empty($params['api_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

     * Function fetching company data by Company Number from YouScore API.

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 array

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

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

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);

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

    private $url = 'https://api.youscore.com.ua/v1/companyInfo/';

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

            return [];

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

        'api_key' => ['required' => 1, 'purifyType' => 'Text', 'label' => 'LBL_API_KEY'],

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

            'economicActivityCode' => '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

            'name' => 'company',

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

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

    /** {@inheritdoc} */

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

        $this->setApiKey();

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

            'address' => 'addresslevel8a',

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

        ],

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

     * @param string $companyNumber

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

            'label' => 'Registration number 1',

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

    /** {@inheritdoc} */

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

     * @return void

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

                    'Authorization' => 'Bearer ' . $this->apiKey

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

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

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

            'address' => 'addresslevel8a',

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

    ];

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

    /** @var string YouScore sever address */

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

    /** @var string Api Key. */

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

    /** {@inheritdoc} */

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

        }

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

     */

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

    private function getDataFromApi(string $companyNumber): void

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

            }

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

     */

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

            'companyNumber' => 'registration_number_1',

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

        $this->getDataFromApi($companyNumber);

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 \App\Utils::flattenKeys($data, 'ucfirst');

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

            'name' => 'accountname',

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

            'economicActivityDescription' => 'description'

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

            'economicActivityDescription' => 'description'

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

        $this->loadData();

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

            ])->get($this->url . $companyNumber);

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

     * @param array $data

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

            'name' => 'vendorname',

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

    protected $modulesFieldsMap = [

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

    ];

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

    {

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

    public function search(): array

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

    }

There are no issues that match your filters.

Category
Status