Strimoid/Strimoid

View on GitHub
app/Providers/EventsServiceProvider.php

Summary

Maintainability
A
1 hr
Test Coverage

Method boot has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function boot(Dispatcher $events): void
    {
        $this->app->booted(function () {
            if (Request::getUser() && Request::getPassword()) {
                return Auth::onceBasic('name');
Severity: Minor
Found in app/Providers/EventsServiceProvider.php - About 1 hr to fix

    Avoid using static access to class '\Illuminate\Support\Facades\Request' in method 'boot'.
    Open

                if (Request::getUser() && Request::getPassword()) {

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

                $user->last_login = Carbon::now();

    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 '\Illuminate\Support\Facades\Request' in method 'boot'.
    Open

                if (Request::getUser() && Request::getPassword()) {

    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 '\Illuminate\Support\Facades\Auth' in method 'boot'.
    Open

                    return Auth::onceBasic('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 using static access to class '\Illuminate\Support\Str' in method 'boot'.
    Open

                        $text = Str::limit($text, 100);

    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 '\Strimoid\Facades\Guzzle' in method 'boot'.
    Open

                        Guzzle::post($url, ['json' => [
                            'room' => '#strimoid-entries',
                            'text' => '[' . $entry->group->name . '] '
                                . $entry->user->name . ': ' . $text,
                        ]]);

    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 '\Strimoid\Facades\Guzzle' in method 'boot'.
    Open

                        Guzzle::post($url, ['json' => [
                            'room' => '#strimoid',
                            'text' => 'Mamy nowego użytkownika ' . $user->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 using static access to class '\Illuminate\Support\Facades\Request' in method 'boot'.
    Open

                $user->last_ip = Request::getClientIp();

    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 empty try-catch blocks in boot.
    Open

                    } catch (\Exception) {
                    }

    EmptyCatchBlock

    Since: 2.7.0

    Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

    Example

    class Foo {
    
      public function bar()
      {
          try {
              // ...
          } catch (Exception $e) {} // empty catch block
      }
    }

    Source https://phpmd.org/rules/design.html#emptycatchblock

    Avoid using empty try-catch blocks in boot.
    Open

                    } catch (\Exception) {
                    }

    EmptyCatchBlock

    Since: 2.7.0

    Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

    Example

    class Foo {
    
      public function bar()
      {
          try {
              // ...
          } catch (Exception $e) {} // empty catch block
      }
    }

    Source https://phpmd.org/rules/design.html#emptycatchblock

    There are no issues that match your filters.

    Category
    Status