sebastianmonzel/webfiles-framework-php

View on GitHub
source/core/datasystem/database/MDatabaseConnection.php

Summary

Maintainability
A
35 mins
Test Coverage
D
65%

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

        $host = null,
        $database = null,
        $tablePrefix = null,
        $username = null,
        $password = null)
Severity: Minor
Found in source/core/datasystem/database/MDatabaseConnection.php - About 35 mins to fix

Remove error control operator '@' on line 86.
Open

    public function connect()
    {
        try {
            $this->connection = @new \mysqli(
                $this->host,

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

Missing class import via use statement (line '86', column '38').
Open

            $this->connection = @new \mysqli(

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

Remove error control operator '@' on line 111.
Open

    public function close()
    {
        @$this->connection->close();
    }

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

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

        } else {
            echo mysqli_connect_error();
            return false;
        }

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

There are no issues that match your filters.

Category
Status