YetiForceCompany/YetiForceCRM

View on GitHub
app/Integrations/Magento/Synchronizer/Maps/Customer.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

The method getDataCrm has a boolean flag argument $onEdit, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function getDataCrm(bool $onEdit = false): array

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Avoid assigning values to variables in if clauses and the like (line '44', column '14').
Open

    public function getDataCrm(bool $onEdit = false): array
    {
        $parsedData = parent::getDataCrm($onEdit);
        if (!empty($shippingAddress = $this->getAddressDataCrm('shipping'))) {
            $parsedData = \array_replace_recursive($parsedData, $shippingAddress);

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 assigning values to variables in if clauses and the like (line '47', column '14').
Open

    public function getDataCrm(bool $onEdit = false): array
    {
        $parsedData = parent::getDataCrm($onEdit);
        if (!empty($shippingAddress = $this->getAddressDataCrm('shipping'))) {
            $parsedData = \array_replace_recursive($parsedData, $shippingAddress);

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

Define a constant instead of duplicating this literal "gender" 3 times.
Open

        'salutationtype' => 'gender',

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

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

        if (!empty($billingAddress = $this->getAddressDataCrm('billing'))) {

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

    public function getDataCrm(bool $onEdit = false): array

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

            $parsedData = $this->parsePhone('mobile', $parsedData);

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

        return $this->dataCrm = $parsedData;

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

    protected $moduleName = 'Accounts';

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

    public static $mappedFields = [

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

        $parsedData = parent::getDataCrm($onEdit);

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

    public static $additionalFieldsCrm = [

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

    {

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

            $parsedData = \array_replace_recursive($parsedData, $billingAddress);

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

        'salutationtype' => 'gender',

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

        }

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

        'lastname' => 'lastname',

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

        'birthday' => 'dob',

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

        'email' => 'email',

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

        if (!empty($shippingAddress = $this->getAddressDataCrm('shipping'))) {

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

        'firstname' => 'firstname',

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

        'gender' => 'gender',

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 (!empty($parsedData['mobile'])) {

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

        }

Line exceeds 120 characters; contains 182 characters
Open

 * The file is part of the paid functionality. Using the file is allowed only after purchasing a subscription. File modification allowed only with the consent of the system producer.

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

        if (!empty($parsedData['phone'])) {

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

            $parsedData = $this->parsePhone('phone', $parsedData);

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

    ];

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

        'leadsource' => 'Magento',

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

            $parsedData = \array_replace_recursive($parsedData, $shippingAddress);

There are no issues that match your filters.

Category
Status