kylekatarnls/business-time

View on GitHub
src/BusinessTime/Laravel/ServiceProvider.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Avoid using static access to class '\Illuminate\Support\Facades\Date' in method 'getCarbonClasses'.
Invalid

            (($now = Date::now()) instanceof \DateTimeInterface) &&

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

    private function getCarbonClasses(): array
    {
        $classes = array_filter([
            Carbon::class,
            CarbonImmutable::class,

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 '\Cmixin\BusinessTime' in method 'boot'.
Open

        BusinessTime::enable(
            $this->getCarbonClasses(),
            array_merge($config, $openingHours)
        );

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

    private function getCarbonClasses(): array
    {
        $classes = array_filter([
            Carbon::class,
            CarbonImmutable::class,

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

Line exceeds 120 characters; contains 132 characters
Open

        $openingHours = $this->proceedConfig($config['opening-hours'] ?? $config['opening_hours'] ?? $config['openingHours'] ?? []);

There are no issues that match your filters.

Category
Status