YetiForceCompany/YetiForceCRM

View on GitHub
app/Map/Address/Base.php

Summary

Maintainability
A
35 mins
Test Coverage
F
17%

Function getDataFromRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDataFromRequest(\App\Request $request): array
    {
        $data = [];
        foreach ($this->getCustomFields() as $fieldName => $fieldModel) {
            if ($request->has($fieldName)) {
Severity: Minor
Found in app/Map/Address/Base.php - About 35 mins 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

Avoid using static access to class '\Vtiger_Field_Model' in method 'getCustomFields'.
Open

            $fields[$fieldName] = \Vtiger_Field_Model::init('Settings:ApiAddress', $configData, $fieldName);
Severity: Minor
Found in app/Map/Address/Base.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 using static access to class '\App\Map\Address' in method '__construct'.
Open

}
Severity: Minor
Found in app/Map/Address/Base.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 '=>' (T_DOUBLE_ARROW), expecting ',' or ')'
Open

                    $codes = array_filter($codes, fn ($code) => 2 === \strlen($code) && preg_match('/^[a-zA-Z]+$/', $code));
Severity: Critical
Found in app/Map/Address/Base.php by phan

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

    public function __construct()
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    public function getName(): string
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    public function getDocUrl(): string
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    public $docUrl = '';
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

            if ($request->has($fieldName)) {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                $value = $fieldModel->getDBValue($value);
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                    'type' => $this->getName(),
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    public $customFields = [];
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    public function isConfigured()
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @return array
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @return bool
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        foreach ($this->customFields as $fieldName => $configData) {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Gets data from request.
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                $fieldUITypeModel->validate($value, true);
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        return $data;
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @return string
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        return $this->isConfigured();
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Provider name.
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Config data.
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    public function isActive()
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @return bool
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @param array $data
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        return $fields;
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    public function getDataFromRequest(\App\Request $request): array
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                    $value = implode(',', $codes);
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Get provider name.
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    public function validate(): bool
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @var array
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        return (bool) ($this->config['active'] ?? 0);
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        $data = [];
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                ];
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @var array
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        return !empty($this->config['key']);
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @return array
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                    'name' => $fieldName,
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @return string
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Custom Fields.
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Function checks if  provider been configured?
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                $value = $request->getByType($fieldName, $fieldModel->get('purifyType'));
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

Line exceeds 120 characters; contains 124 characters
Open

                    $codes = array_filter($codes, fn ($code) => 2 === \strlen($code) && preg_match('/^[a-zA-Z]+$/', $code));
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

            }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Validate configuration.
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @return bool
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Construct.
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @var string
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

            }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Get provider documentation url address.
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    public $name;
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Get provider custom fields.
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        foreach ($this->getCustomFields() as $fieldName => $fieldModel) {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                $fieldUITypeModel = $fieldModel->getUITypeModel();
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Function checks if provider is active.
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    public function getCustomFields(array $data = []): array
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        $fields = [];
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

            $fields[$fieldName] = \Vtiger_Field_Model::init('Settings:ApiAddress', $configData, $fieldName);
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                    $codes = array_map('trim', explode(',', $value));
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    public $config;
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Provider documentation url address.
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                $configData['fieldvalue'] = $data[$fieldName];
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                if ($value && 'country_codes' === $fieldName) {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                    $codes = array_filter($codes, fn ($code) => 2 === \strlen($code) && preg_match('/^[a-zA-Z]+$/', $code));
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                $data[] = [
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        return $this->docUrl;
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @param $value string
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        $this->config = \App\Map\Address::getConfig()[$this->getName()] ?? [];
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    }
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

                    'val' => $value
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * Find address.
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @return array
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @var string
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

            if (isset($data[$fieldName])) {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     * @param \App\Request $request
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

        return basename(str_replace('\\', '/', static::class));
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     */
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    {
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    /**
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

    abstract public function find($value);
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

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

     *
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

Space before opening parenthesis of function call prohibited
Open

                    $codes = array_filter($codes, fn ($code) => 2 === \strlen($code) && preg_match('/^[a-zA-Z]+$/', $code));
Severity: Minor
Found in app/Map/Address/Base.php by phpcodesniffer

There are no issues that match your filters.

Category
Status