lib/Ajde/Shop/Transaction/Provider.php

Summary

Maintainability
A
0 mins
Test Coverage

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

            throw new Ajde_Exception('Payment provider '.$name.' not found');

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

Avoid using static access to class 'Ajde_Log' in method 'ping'.
Open

            Ajde_Log::log('Ping for '.$host.':'.$port.' (timeout='.$timeout.') failed');

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

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

        } else {
            return true;
        }

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

Avoid using static access to class 'Ajde_Core_ExternalLibs' in method 'getProvider'.
Open

        $providerClass = Ajde_Core_ExternalLibs::getClassname('Ajde_Shop_Transaction_Provider_'.self::classnameToUppercase($name));

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 unused local variables such as '$errstr'.
Open

        $fsock = fsockopen($host, $port, $errno, $errstr, $timeout);

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Avoid unused local variables such as '$errno'.
Open

        $fsock = fsockopen($host, $port, $errno, $errstr, $timeout);

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

TODO found
Open

            // TODO:

The class Ajde_Shop_Transaction_Provider is not named in CamelCase.
Open

abstract class Ajde_Shop_Transaction_Provider extends Ajde_Object_Standard implements Ajde_Shop_Transaction_Provider_Interface
{
    public $returnRoute = 'shop/transaction:callback/';

    /**

CamelCaseClassName

Since: 0.2

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

Example

class class_name {
}

Source

The class Ajde_Shop_Transaction_Provider_Interface is not named in CamelCase.
Open

interface Ajde_Shop_Transaction_Provider_Interface
{
    public function getName();

    public function getLogo();

CamelCaseClassName

Since: 0.2

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

Example

class class_name {
}

Source

There are no issues that match your filters.

Category
Status