Cloudstek/mollie-php-api

View on GitHub
src/Resource/Customer/SubscriptionResource.php

Summary

Maintainability
A
1 hr
Test Coverage

Function create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function create($amount, $interval, $description, $times = null, array $opts = array())
    {
        // Check number of times
        if (isset($times) && ($times < 1 || !is_numeric($times))) {
            throw new \InvalidArgumentException("Invalid number of charges for this subscription. Please enter a number of 1 or more, or leave null for an ongoing subscription.");
Severity: Minor
Found in src/Resource/Customer/SubscriptionResource.php - About 55 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

Method create has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function create($amount, $interval, $description, $times = null, array $opts = array())
Severity: Minor
Found in src/Resource/Customer/SubscriptionResource.php - About 35 mins to fix

    Missing class import via use statement (line '93', column '31').
    Open

                        throw new \InvalidArgumentException("Option startDate must be a valid DateTime object or date string, preferably yyyy-mm-dd.");

    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

    Missing class import via use statement (line '91', column '46').
    Open

                        $opts['startDate'] = new \DateTime($opts['startDate']);

    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

    Missing class import via use statement (line '84', column '23').
    Open

                throw new \InvalidArgumentException("Invalid number of charges for this subscription. Please enter a number of 1 or more, or leave null for an ongoing subscription.");

    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

    There are no issues that match your filters.

    Category
    Status