timegridio/timegrid

View on GitHub
app/TG/BusinessService.php

Summary

Maintainability
A
0 mins
Test Coverage
A
96%

Avoid assigning values to variables in if clauses and the like (line '32', column '13').
Open

    public function register(User $user, $data, $category)
    {
        $slug = str_slug($data['name']);

        if ($business = self::getExisting($user, $slug)) {
Severity: Minor
Found in app/TG/BusinessService.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 '\Timegridio\Concierge\Models\Category' in method 'setCategory'.
Open

        $category = Category::find($category);
Severity: Minor
Found in app/TG/BusinessService.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

Avoid using static access to class '\Timegridio\Concierge\Models\Category' in method 'register'.
Open

        $category = Category::find($category);
Severity: Minor
Found in app/TG/BusinessService.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

There are no issues that match your filters.

Category
Status