lib/Ajde/Shop/Transaction/Provider/Mollie/API/Client.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method performHttpCall has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function performHttpCall($http_method, $api_method, $http_body = null)
    {
        if (empty($this->api_key)) {
            throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
        }
Severity: Minor
Found in lib/Ajde/Shop/Transaction/Provider/Mollie/API/Client.php - About 1 hr to fix

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

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }
    Severity: Minor
    Found in lib/Ajde/Shop/Transaction/Provider/Mollie/API/Client.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

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

            $this->payments = new Mollie_API_Resource_Payments($this);

    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 '165', column '23').
    Open

                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');

    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 '95', column '30').
    Open

            $this->issuers = new Mollie_API_Resource_Issuers($this);

    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 '96', column '30').
    Open

            $this->methods = new Mollie_API_Resource_Methods($this);

    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 '131', column '23').
    Open

                throw new Mollie_API_Exception("Invalid api key: \"{$api_key}\". An API key must start with \"test_\" or \"live_\".");

    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 '225', column '23').
    Open

                throw new Mollie_API_Exception('Unable to communicate with Mollie ('.curl_errno($ch).'): '.curl_error($ch));

    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

    The method performHttpCall uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $http_method);
                }

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    The parameter $http_body is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The property $api_key is not named in camelCase.
    Open

    class Mollie_API_Client
    {
        /**
         * Version of our client.
         */

    CamelCasePropertyName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name attributes.

    Example

    class ClassName {
        protected $property_name;
    }

    Source

    The parameter $api_key is not named in camelCase.
    Open

        public function setApiKey($api_key)
        {
            if (!preg_match('!^(?:live|test)_\\w+$!', $api_key)) {
                throw new Mollie_API_Exception("Invalid api key: \"{$api_key}\". An API key must start with \"test_\" or \"live_\".");
            }

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    Avoid variables with short names like $ch. Configured minimum length is 3.
    Open

            $ch = curl_init($url);

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    The class Mollie_API_Client is not named in CamelCase.
    Open

    class Mollie_API_Client
    {
        /**
         * Version of our client.
         */

    CamelCaseClassName

    Since: 0.2

    It is considered best practice to use the CamelCase notation to name classes.

    Example

    class class_name {
    }

    Source

    The property $api_endpoint is not named in camelCase.
    Open

    class Mollie_API_Client
    {
        /**
         * Version of our client.
         */

    CamelCasePropertyName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name attributes.

    Example

    class ClassName {
        protected $property_name;
    }

    Source

    The parameter $api_method is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $http_method is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $version_string is not named in camelCase.
    Open

        public function addVersionString($version_string)
        {
            $this->versionStrings[] = str_replace([' ', "\t", "\n", "\r"], '-', $version_string);
        }

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The variable $api_key is not named in camelCase.
    Open

        public function setApiKey($api_key)
        {
            if (!preg_match('!^(?:live|test)_\\w+$!', $api_key)) {
                throw new Mollie_API_Exception("Invalid api key: \"{$api_key}\". An API key must start with \"test_\" or \"live_\".");
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $curl_version is not named in camelCase.
    Open

        public function __construct()
        {
            $this->payments = new Mollie_API_Resource_Payments($this);
            $this->issuers = new Mollie_API_Resource_Issuers($this);
            $this->methods = new Mollie_API_Resource_Methods($this);

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $request_headers is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $request_headers is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $user_agent is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $http_body is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $request_headers is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $http_method is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $request_headers is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $version_string is not named in camelCase.
    Open

        public function addVersionString($version_string)
        {
            $this->versionStrings[] = str_replace([' ', "\t", "\n", "\r"], '-', $version_string);
        }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $curl_version is not named in camelCase.
    Open

        public function __construct()
        {
            $this->payments = new Mollie_API_Resource_Payments($this);
            $this->issuers = new Mollie_API_Resource_Issuers($this);
            $this->methods = new Mollie_API_Resource_Methods($this);

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $curl_version is not named in camelCase.
    Open

        public function __construct()
        {
            $this->payments = new Mollie_API_Resource_Payments($this);
            $this->issuers = new Mollie_API_Resource_Issuers($this);
            $this->methods = new Mollie_API_Resource_Methods($this);

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $api_method is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $user_agent is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $request_headers is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $api_key is not named in camelCase.
    Open

        public function setApiKey($api_key)
        {
            if (!preg_match('!^(?:live|test)_\\w+$!', $api_key)) {
                throw new Mollie_API_Exception("Invalid api key: \"{$api_key}\". An API key must start with \"test_\" or \"live_\".");
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $request_headers is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $http_method is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $api_key is not named in camelCase.
    Open

        public function setApiKey($api_key)
        {
            if (!preg_match('!^(?:live|test)_\\w+$!', $api_key)) {
                throw new Mollie_API_Exception("Invalid api key: \"{$api_key}\". An API key must start with \"test_\" or \"live_\".");
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $http_body is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $request_headers is not named in camelCase.
    Open

        public function performHttpCall($http_method, $api_method, $http_body = null)
        {
            if (empty($this->api_key)) {
                throw new Mollie_API_Exception('You have not set an api key. Please use setApiKey() to set the API key.');
            }

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status