YetiForceCompany/YetiForceCRM

View on GitHub
app/RecordCollectors/UsaEdgarRegistryFromSec.php

Summary

Maintainability
A
0 mins
Test Coverage
D
68%

Avoid using static access to class '\App\Log' in method 'getDataFromApi'.
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

        $this->data = \App\Utils::flattenKeys($this->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 'getDataFromApi'.
Open

            $this->data = isset($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 = 'YetiForceRcUsaEdgar';

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

    public $formFieldsToRecordMap = [
        'Accounts' => [
            'name' => 'accountname',
            'cik' => 'registration_number_1',
            'ein' => 'vat_id',

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

            'addressesBusinessStreet1' => 'addresslevel8a',

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

            'addressesMailingsCity' => 'addresslevel5b',

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

            'cik' => 'registration_number_1',

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

            'ein' => 'vat_id',

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

            'addressesMailingZipCode' => 'addresslevel7b',

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

    /** {@inheritdoc} */

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

            'addressesBusinessCity' => 'addresslevel5a',

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

            'addressesBusinessStateOrCountryDescription' => 'addresslevel2a',

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

            'phone' => 'phone',

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

    /** @var string SEC sever address */

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

    public $icon = 'yfi-edgar-usa';

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

        ],

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

            'addressesBusinessZipCode' => 'addresslevel7a',

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

            'addressesBusinessStreet2' => 'buildingnumbera',

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

            'addressesBusinessStateOrCountryDescription' => 'addresslevel2a',

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

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

    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

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

        'Accounts' => [

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

            'cik' => 'registration_number_1',

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

        $this->parseData();

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

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 int Central Index Key length */

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

            'addressesBusinessStreet2' => 'buildingnumbera',

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

            'addressesBusinessZipCode' => 'addresslevel7a',

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

            'addressesMailingZipCode' => 'addresslevel7b',

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

        ],

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

            'addressesBusinessZipCode' => 'addresslevel7a',

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

            'addressesBusinessStreet1' => 'addresslevel8a',

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

            'addressesMailingStreet2' => 'buildingnumberb',

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

        'cik' => [

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

        'Leads' => [

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

    const CIK_LEN = 10;

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

            'name' => 'accountname',

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

            'cik' => 'registration_number_1',

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

            'ein' => 'vat_id',

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

        $this->getDataFromApi($cik);

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

        if (\strlen($cik) < self::CIK_LEN) {

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

    public $label = 'LBL_USA_EDGAR';

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

            'addressesBusinessStreet2' => 'buildingnumbera',

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

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

        'Vendors' => [

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 = 'YetiForceRcUsaEdgar';

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

            'cik' => 'registration_number_1',

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

            'cik' => 'registration_number_1',

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

    /** {@inheritdoc} */

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

    public $docUrl = 'https://www.sec.gov/edgar/sec-api-documentation';

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

            'webiste' => 'website',

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

            'sic' => 'siccode',

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

            'addressesBusinessStateOrCountryDescription' => 'addresslevel2b'

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

            'phone' => 'phone',

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

            'cik' => 'registration_number_1',

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

            'ein' => 'vat_id',

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

            'webiste' => 'website',

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

            'addressesBusinessStateOrCountryDescription' => 'addresslevel2b'

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

    protected $url = 'https://data.sec.gov/submissions/CIK';

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

            'name' => 'vendorname',

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

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

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

            'addressesBusinessCity' => 'addresslevel5a',

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

            'addressesMailingStreet2' => 'buildingnumberb',

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

            'addressesBusinessStateOrCountryDescription' => 'addresslevel2a',

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

        if (!$cik) {

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 $description = 'LBL_USA_EDGAR_DESC';

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

            'webiste' => 'website',

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

            'sic' => 'siccode',

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

            'ein' => 'vat_id',

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

            'addressesBusinessStateOrCountryDescription' => 'addresslevel2a',

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 function getDataFromApi(string $cik): void

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

            'addressesBusinessCity' => 'addresslevel5a',

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

            'addressesMailingsCity' => 'addresslevel5b',

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

            'addressesBusinessStreet2' => 'buildingnumbera',

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

            'typeofdata' => 'V~M',

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

            'ein' => 'vat_id',

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

            'addressesBusinessStateOrCountryDescription' => 'addresslevel2a',

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

        ],

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

    public $allowedModules = ['Accounts', 'Leads', 'Partners', 'Vendors', 'Competition'];

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

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

        $cik = str_replace([' ', ',', '.', '-'], '', $this->request->getByType('cik', '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

    /** {@inheritdoc} */

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

            'phone' => 'phone',

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

            'addressesMailingStreet1' => 'addresslevel8b',

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

            'addressesBusinessStreet2' => 'buildingnumbera',

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

            'addressesBusinessZipCode' => 'addresslevel7a',

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

            'addressesMailingStreet1' => 'addresslevel8b',

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

            'addressesBusinessZipCode' => 'addresslevel7a',

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

     * Function finding company data by Central Index Key (CIK).

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

            'addressesBusinessStreet1' => 'addresslevel8a',

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

        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

            return;

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

        unset($this->data['filings']);

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

            $response = \App\RequestHttp::getClient()->get($this->url . $cik . '.json', [

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 = isset($response) ? \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

    private function parseData(): 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

            $cik = str_repeat('0', $countZeroToAdd) . $cik;

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

            \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

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

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

     * @return void

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

        if (empty($this->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

        $this->data = \App\Utils::flattenKeys($this->data, 'ucfirst');

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

            $countZeroToAdd = self::CIK_LEN - \strlen($cik);

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

     * Function parsing data to fields from Securities and Exchange Commission API.

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

                    'User-Agent' => 'YetiForce S. A. devs@yetiforce.com',

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

    /**

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