dmitry-kulikov/yii2-braintree

View on GitHub

Showing 265 of 271 total issues

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

    public function getPlanIds(bool $allowCaching = true): array
Severity: Minor
Found in src/Braintree.php by phpmd

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

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

    public static function getAllPlans(bool $allowCaching = true): array
Severity: Minor
Found in src/BraintreeForm.php by phpmd

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

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

    public function sale(bool $submitForSettlement = true, bool $storeInVaultOnSuccess = true): array
Severity: Minor
Found in src/Braintree.php by phpmd

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

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

    public function getAllPlans(bool $allowCaching = true): array
Severity: Minor
Found in src/Braintree.php by phpmd

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

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

    public static function getPlanIds(bool $allowCaching = true): array
Severity: Minor
Found in src/BraintreeForm.php by phpmd

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

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

    public static function getPlanById(string $planId, bool $allowCaching = true): ?Plan
Severity: Minor
Found in src/BraintreeForm.php by phpmd

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

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

            'customer_lastName' => 'Last Name',
Severity: Critical
Found in src/BraintreeForm.php by sonar-php

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.

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

                    'options' => $options,
Severity: Critical
Found in src/BraintreeForm.php by sonar-php

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.

Define a constant instead of duplicating this literal "result" 9 times.
Open

        return ['status' => $result->success, 'result' => $result];
Severity: Critical
Found in src/Braintree.php by sonar-php

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.

Reference to undeclared class \yii\bootstrap\ActiveField (Did you mean class \tuyakhov\braintree\ActiveField)
Open

        parent::init();
Severity: Critical
Found in src/ActiveField.php by phan

Call to method merchantId from undeclared class \Braintree\Configuration
Open

            Configuration::$attribute($this->$attribute);
Severity: Critical
Found in src/Braintree.php by phan

Assigning array<string></string> to property but \tuyakhov\braintree\Braintree->options is array<string>&gt;|array<string></string></string>
Open

        $this->options['amount'] = round($amount, 2);
Severity: Minor
Found in src/Braintree.php by phan

Class "BraintreeForm" has 31 methods, which is greater than 20 authorized. Split it into smaller classes.
Open

class BraintreeForm extends Model
Severity: Major
Found in src/BraintreeForm.php by sonar-php

A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.

Possibly zero references to public method \tuyakhov\braintree\ActiveField::init()
Open

    public function init()
Severity: Minor
Found in src/ActiveField.php by phan

Reference to undeclared property \tuyakhov\braintree\ActiveField->attribute
Open

        $inputName = explode('_', $this->attribute);
Severity: Minor
Found in src/ActiveField.php by phan

Class extends undeclared class \yii\base\Component
Open

class Braintree extends Component
Severity: Critical
Found in src/Braintree.php by phan

Possibly zero references to public property \tuyakhov\braintree\Braintree->environment
Open

    public $environment = 'sandbox';
Severity: Minor
Found in src/Braintree.php by phan

Assigning array<string></string> to property but \tuyakhov\braintree\Braintree->options is array<string></string>
Open

        $this->options['options']['storeInVaultOnSuccess'] = $storeInVaultOnSuccess;
Severity: Minor
Found in src/Braintree.php by phan

Call to method sale from undeclared class \Braintree\Transaction
Open

        $result = Transaction::sale($this->options);
Severity: Critical
Found in src/Braintree.php by phan

Return type of getAllPlans() is undeclared type \Braintree\Plan[]
Open

    public function getAllPlans(bool $allowCaching = true): array
Severity: Minor
Found in src/Braintree.php by phan
Severity
Category
Status
Source
Language