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',
]);
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'));
Avoid using undefined variables such as '$options' which will lead to PHP notices. Open
$skins = Profile::$options['skins'];
- Read upRead up
- Exclude checks
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'];
- Read upRead up
- Exclude checks
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'];
- Read upRead up
- Exclude checks
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'];
- Read upRead up
- Exclude checks
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
*/
- Read upRead up
- Exclude checks
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;
}
- Read upRead up
- Exclude checks
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
}
}
}