YetiForceCompany/YetiForceCRM

View on GitHub
app/RecordCollectors/UkCompaniesHouse.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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

    private function getDataFromApiByNcr($ncr): array
    {
        try {
            $response = \App\RequestHttp::getClient()->request('GET', $this->url . '/company/' . $ncr, [
                'auth' => [$this->apiKey, ''],
Severity: Minor
Found in app/RecordCollectors/UkCompaniesHouse.php - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Missing class import via use statement (line '275', column '14').
Open

            throw new \App\Exceptions\IllegalValue('You must fist setup Api Key in Config Panel', 403);

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\Json' in method 'getDataFromApiByNcr'.
Open

        $data = isset($response) ? $this->parseData(\App\Json::decode($response->getBody()->getContents(), true)) : [];

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 'getDataFromApiByName'.
Open

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

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

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 'getPersonsWithSignificantControl'.
Open

}

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

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\Log' in method 'getDataFromApiByNcr'.
Open

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

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 '272', column '8').
Open

    private function setApiKey(): void
    {
        if (($params = $this->getParams()) && !empty($params['api_key'])) {
            $this->apiKey = $params['api_key'];
        } else {

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 'search'.
Open

                '' => \App\Language::translate('LBL_UK_CH_NOT_FOUND_NO_DATA', 'Other.RecordCollector')

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 'getPersonsWithSignificantControl'.
Open

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

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 search uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->displayType = 'Summary';
            $this->response['fields'] = [
                '' => \App\Language::translate('LBL_UK_CH_NOT_FOUND_NO_DATA', 'Other.RecordCollector')
            ];

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 'getDataFromApiByName'.
Open

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

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 = 'YetiForceRcUkCompaniesHouse';
Severity: Critical
Found in app/RecordCollectors/UkCompaniesHouse.php by phan

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

        'Accounts' => [
            'company_name' => 'accountname',
            'company_number' => 'registration_number_1',
            'sic_codes0' => 'siccode',
            'registered_office_addressAddress_line_1' => 'addresslevel8a',
Severity: Major
Found in app/RecordCollectors/UkCompaniesHouse.php and 4 other locations - About 30 mins to fix
app/RecordCollectors/Gus.php on lines 44..62
app/RecordCollectors/Gus.php on lines 63..81
app/RecordCollectors/VatifyEu.php on lines 71..89
app/RecordCollectors/VatifyEu.php on lines 90..108

Duplicated Code

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

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

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

Tuning

This issue has a mass of 91.

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

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

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

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

Refactorings

Further Reading

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

    public $formFieldsToRecordMap = [
        'Accounts' => [
            'company_name' => 'accountname',
            'company_number' => 'registration_number_1',
            'sic_codes0' => 'siccode',

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 $allowedModules = ['Accounts', 'Leads', 'Vendors', '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

    /** @var string[] Keys to skip in additional */

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

    const LIMIT = 4;

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

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

    /** {@inheritdoc} */

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

    /** @var int Limit for fetching companies */

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-companies-house-uk';

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

    public $description = 'LBL_UK_CH_DESC';

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

    const EXTERNAL_URL = 'https://find-and-update.company-information.service.gov.uk/company/';

Line exceeds 120 characters; contains 146 characters
Open

    const REMOVE_KEYS = ['linksSelf', 'linksFiling_history', 'linksOfficers', 'linksPersons_with_significant_control-statements', 'linksCharges'];

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

    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

    public $docUrl = 'https://developer.company-information.service.gov.uk/';

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

    const REMOVE_KEYS = ['linksSelf', 'linksFiling_history', 'linksOfficers', 'linksPersons_with_significant_control-statements', 'linksCharges'];

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

    public $label = 'LBL_UK_CH';

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

            'registered_office_addressPostal_code' => 'addresslevel7a',

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

            'registered_office_addressLocality' => 'addresslevel5a',

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

        ],

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

            'service_addressCountry' => 'addresslevel1b',

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

    ];

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

            'company_number' => 'registration_number_1',

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

            'registered_office_addressLocality' => 'addresslevel5a',

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

            'service_addressRegion' => 'addresslevel4b',

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

            'company_name' => 'vendorname',

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

            'registered_office_addressAddress_line_1' => 'addresslevel8a',

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

            'service_addressPostal_code' => 'addresslevel7b',

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

            'registered_office_addressAddress_line_2' => 'addresslevel3a',

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

            'labelModule' => '_Base',

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

        if (!$this->isActive()) {

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

            $this->response['fields'] = [

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 (isset($data['linksPersons_with_significant_control'])) {

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

            'registered_office_addressAddress_line_2' => 'addresslevel3a',

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

        } elseif ($companyName) {

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 $ncr

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

            $response = \App\RequestHttp::getClient()->request('GET', $this->url . '/company/' . $ncr, [

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

    /** @var string CH sever address */

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

            'company_name' => 'accountname',

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

            'sic_codes0' => 'siccode',

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

            'service_addressAddress_line_1' => 'addresslevel8b',

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

            'service_addressLocality' => 'addresslevel5b',

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

            'registered_office_addressAddress_line_1' => 'addresslevel8a',

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

            'registered_office_addressPo_box' => 'poboxa',

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

        'Accounts' => [

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

            'companyName' => 'company'

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

            'ncr' => 'registration_number_1',

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

        $this->moduleName = $this->request->getModule();

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

        if ($ncr) {

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

     * Function fetching from Companies House API.

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

     */

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

        try {

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

            'service_addressAddress_line_1' => 'addresslevel8b',

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

            'registered_office_addressRegion' => 'addresslevel4a',

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

            'registered_office_addressPo_box' => 'poboxa',

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

            'registered_office_addressLocality' => 'addresslevel5a',

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

            'registered_office_addressRegion' => 'addresslevel4a',

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

            'service_addressPo_box' => 'poboxb',

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

    /** {@inheritdoc} */

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

            'companyName' => 'vendorname'

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

        $this->setApiKey();

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

        $data = isset($response) ? $this->parseData(\App\Json::decode($response->getBody()->getContents(), true)) : [];

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

            'registered_office_addressRegion' => 'addresslevel4a',

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

            'registered_office_addressLocality' => 'addresslevel5a',

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

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

        }

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

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

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

            'registered_office_addressPostal_code' => 'addresslevel7a',

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

            'registered_office_addressRegion' => 'addresslevel4a',

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

        ],

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

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

            return [];

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

            'service_addressLocality' => 'addresslevel5b',

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

            'service_addressPo_box' => 'poboxb',

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

        'companyName' => [

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

    private $url = 'https://api.company-information.service.gov.uk';

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

        $this->loadData();

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

                }

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

            'registered_office_addressCountry' => 'addresslevel1a',

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

            'service_addressCountry' => 'addresslevel1b',

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

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

        'ncr' => [

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

            'label' => 'Account name',

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

            $this->getDataFromApiByName($companyName);

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

        'Accounts' => [

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

            'company_name' => 'company',

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

        ]

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

    protected string $addOnName = 'YetiForceRcUkCompaniesHouse';

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

        ],

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

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

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

                '' => \App\Language::translate('LBL_UK_CH_NOT_FOUND_NO_DATA', 'Other.RecordCollector')

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

    }

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

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

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

            'service_addressAddress_line_2' => 'addresslevel3b',

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

            'registered_office_addressAddress_line_1' => 'addresslevel8a',

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

            'registered_office_addressAddress_line_2' => 'addresslevel3a',

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

            'service_addressRegion' => 'addresslevel4b',

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

    private $apiKey;

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

    {

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

            ];

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

                if (isset($data[$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

            }

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

     */

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

        $names = [];

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

            'registered_office_addressCountry' => 'addresslevel1a',

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

            'registered_office_addressPo_box' => 'poboxa',

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

            'registered_office_addressPostal_code' => 'addresslevel7a',

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

            'registered_office_addressCountry' => 'addresslevel1a',

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

            'ncr' => '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->data = $this->getDataFromApiByNcr($ncr);

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

                'auth' => [$this->apiKey, ''],

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

        if (!empty($data)) {

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

                    unset($data[$key]);

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

    private function getDataFromApiByName(string $companyName): void

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

    {

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

                $data[$key] = $this->getDataFromApiByNcr($value['company_number']);

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

                    break;

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

            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

    }

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

     * Function fetching persons Persons with significant control .

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

        }

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

     * @return void

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

        $data = [];

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

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

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

     * @param string $companyName

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 parseData(array $data): array

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

    private function getPersonsWithSignificantControl(string $url): array

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

    {

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

            'registered_office_addressAddress_line_1' => 'addresslevel8a',

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

            'registered_office_addressPo_box' => 'poboxa',

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

        ],

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

            'service_addressAddress_line_2' => 'addresslevel3b',

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

        'Leads' => [

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

    /**

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

        try {

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

            foreach ($response['items'] as $key => $value) {

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

     * Function setup Api Key.

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

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

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

        $items = \App\Json::decode($response->getBody()->getContents())['items'];

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

            'registered_office_addressAddress_line_2' => 'addresslevel3a',

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

            'registered_office_addressCountry' => 'addresslevel1a',

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

            'company_number' => 'registration_number_1',

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

        ],

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

    /** @var string CH sever address */

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

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

            foreach (self::REMOVE_KEYS as $key) {

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

     * Function finding NCR Number by company name.

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

     */

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

        $this->data = $data;

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

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

    }

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

            'service_addressPostal_code' => 'addresslevel7b',

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

            'registered_office_addressPostal_code' => 'addresslevel7a',

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

            'company_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

            'companyName' => 'accountname'

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

            'ncr' => 'registration_number_1',

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

            $this->displayType = 'Summary';

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 array

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

    private function getDataFromApiByNcr($ncr): array

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

                    $data['linksPersons_with_significant_control'] .= ' ' . $name;

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

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

    {

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

        }

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

        'Leads' => [

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

            'ncr' => 'registration_number_1',

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

                foreach ($this->getPersonsWithSignificantControl($data['linksPersons_with_significant_control']) as $name) {

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

        return $data;

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

                $this->response['links'][$key] = self::EXTERNAL_URL . $data[$key]['company_number'];

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

        return \App\Utils::flattenKeys($data, 'ucfirst');

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

        try {

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

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

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

    /**

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

    private function setApiKey(): void

Line exceeds 120 characters; contains 124 characters
Open

                foreach ($this->getPersonsWithSignificantControl($data['linksPersons_with_significant_control']) as $name) {

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

                'auth' => [$this->apiKey, ''],

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()->request('GET', $this->url . $url, [

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

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

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

    /**

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

        return $names;

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

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

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

        foreach ($items as $item) {

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

                $names[] = $item['name'];

Line exceeds 120 characters; contains 152 characters
Open

            $response = \App\RequestHttp::getClient()->request('GET', $this->url . '/advanced-search/companies?company_name_includes=' . $companyName, [

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

                }

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

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

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 $url

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

            if ('individual-person-with-significant-control' === $item['kind']) {

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

            }

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

            }

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

                if (self::LIMIT === $key) {

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

     *

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

                'auth' => [$this->apiKey, ''],

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()->request('GET', $this->url . '/advanced-search/companies?company_name_includes=' . $companyName, [

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

    /**

There are no issues that match your filters.

Category
Status