skqr/hateoas

View on GitHub
Http/Url.php

Summary

Maintainability
A
0 mins
Test Coverage

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

            throw new \BadMethodCallException();
Severity: Minor
Found in Http/Url.php by phpmd

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

            throw new \InvalidArgumentException();
Severity: Minor
Found in Http/Url.php by phpmd

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

            throw new \InvalidArgumentException(static::INVALID_URL_ERROR);
Severity: Minor
Found in Http/Url.php by phpmd

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 '74', column '31').
Open

                    throw new \BadMethodCallException();
Severity: Minor
Found in Http/Url.php by phpmd

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 assigning values to variables in if clauses and the like (line '105', column '13').
Open

    public function __toString()
    {
        if ($root = $this->getRoot()) {
            $this->toAbsoluteUrl($root); // Deliberadamente redundante.
        }
Severity: Minor
Found in Http/Url.php by phpmd

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

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

Avoid using static access to class '\GoIntegro\Hateoas\Util\Inflector' in method 'fromString'.
Open

            $method = 'set' . Inflector::camelize($component);
Severity: Minor
Found in Http/Url.php by phpmd

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 __call uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            throw new \BadMethodCallException();
        }
Severity: Minor
Found in Http/Url.php by phpmd

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 unused private fields such as '$root'.
Open

    private $root; // La base de una URL relativa.
Severity: Minor
Found in Http/Url.php by phpmd

UnusedPrivateField

Since: 0.2

Detects when a private field is declared and/or assigned a value, but not used.

Example

class Something
{
    private static $FOO = 2; // Unused
    private $i = 5; // Unused
    private $j = 6;
    public function addOne()
    {
        return $this->j++;
    }
}

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

Avoid unused private fields such as '$original'.
Open

    private $original; // La URL a partir de la cuál fue creada la instancia.
Severity: Minor
Found in Http/Url.php by phpmd

UnusedPrivateField

Since: 0.2

Detects when a private field is declared and/or assigned a value, but not used.

Example

class Something
{
    private static $FOO = 2; // Unused
    private $i = 5; // Unused
    private $j = 6;
    public function addOne()
    {
        return $this->j++;
    }
}

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

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

        if (FALSE === $components) {
Severity: Minor
Found in Http/Url.php by phpcodesniffer

Expected 0 spaces after opening bracket; newline found
Open

        if (
Severity: Minor
Found in Http/Url.php by phpcodesniffer

There are no issues that match your filters.

Category
Status