src/Http/Controllers/Profile/ProfileController.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method postChangeCharacter has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function postChangeCharacter(Request $request)
    {
        $request->validate([
            'character_id' => 'integer|exists:character_infos,character_id|required',
        ]);
Severity: Minor
Found in src/Http/Controllers/Profile/ProfileController.php - About 1 hr to fix

    Method postUpdateSharelink has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function postUpdateSharelink(Sharelink $request)
        {
            // Validate our character id is valid for the submitting user
            if ((int) $request->input('user_sharelink_character_id') !== 0) {
                $requested_character = auth()->user()->characters->contains((int) $request->input('user_sharelink_character_id'));
    Severity: Minor
    Found in src/Http/Controllers/Profile/ProfileController.php - About 1 hr to fix

      Avoid using undefined variables such as '$options' which will lead to PHP notices.
      Open

              $skins = Profile::$options['skins'];

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$options' which will lead to PHP notices.
      Open

              $thousand = Profile::$options['thousand_seperator'];

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$options' which will lead to PHP notices.
      Open

              $decimal = Profile::$options['decimal_seperator'];

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$options' which will lead to PHP notices.
      Open

              $sidebar = Profile::$options['sidebar'];

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      The class ProfileController has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
      Open

      class ProfileController extends Controller
      {
          /**
           * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
           */

      CouplingBetweenObjects

      Since: 1.1.0

      A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

      Example

      class Foo {
          /**
           * @var \foo\bar\X
           */
          private $x = null;
      
          /**
           * @var \foo\bar\Y
           */
          private $y = null;
      
          /**
           * @var \foo\bar\Z
           */
          private $z = null;
      
          public function setFoo(\Foo $foo) {}
          public function setBar(\Bar $bar) {}
          public function setBaz(\Baz $baz) {}
      
          /**
           * @return \SplObjectStorage
           * @throws \OutOfRangeException
           * @throws \InvalidArgumentException
           * @throws \ErrorException
           */
          public function process(\Iterator $it) {}
      
          // ...
      }

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

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

              } else {
                  $characters = auth()->user()->characters;
              }

      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