Method createRollOnSuccess
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function createRollOnSuccess($class, $difficulty, RollOnQuality $rollOnQuality, $isSuccess, $resultValue)
The method createBasicRollOnSuccess has a boolean flag argument $isSuccess, which is a certain sign of a Single Responsibility Principle violation. Open
private function createBasicRollOnSuccess($difficulty, RollOnQuality $rollOnQuality, $isSuccess = false, $resultValue = 'foo')
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '24', column '48'). Open
$extendedRollOnSuccessReflection = new \ReflectionClass(ExtendedRollOnSuccess::class);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method createSimpleRollOnSuccess has a boolean flag argument $isSuccess, which is a certain sign of a Single Responsibility Principle violation. Open
private function createSimpleRollOnSuccess($difficulty, RollOnQuality $rollOnQuality, $isSuccess = false, $resultValue = 'foo')
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method I_can_use_it uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
self::assertTrue($extendedRollOnSuccess->isFailure());
self::assertFalse($extendedRollOnSuccess->isSuccess());
}
- 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
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid excessively long variable names like $extendedRollOnSuccessReflection. Keep variable name length under 20. Open
$extendedRollOnSuccessReflection = new \ReflectionClass(ExtendedRollOnSuccess::class);
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $extendedRollOnSuccess. Keep variable name length under 20. Open
$extendedRollOnSuccess = $extendedRollOnSuccessReflection->newInstanceArgs($simpleRollsOnSuccess);
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $extendedRollOnSuccess. Keep variable name length under 20. Open
$extendedRollOnSuccess = new ExtendedRollOnSuccess(
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $expectedRollOnQuality. Keep variable name length under 20. Open
public function I_can_use_it(RollOnQuality $expectedRollOnQuality, array $simpleRollsOnSuccess, string $expectedResultCode, bool $expectingSuccess)
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $extendedRollOnSuccess. Keep variable name length under 20. Open
$extendedRollOnSuccess = new ExtendedRollOnSuccess(
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
The method I_can_not_use_different_rolls_on_quality is not named in camelCase. Open
public function I_can_not_use_different_rolls_on_quality(SimpleRollOnSuccess $firstSimpleRoll, SimpleRollOnSuccess $secondSimpleRoll)
{
$this->expectException(\DrdPlus\RollsOn\QualityAndSuccess\Exceptions\RollOnQualityHasToBeTheSame::class);
new ExtendedRollOnSuccess($firstSimpleRoll, $secondSimpleRoll);
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_use_only_unique_success_codes is not named in camelCase. Open
public function I_can_use_only_unique_success_codes()
{
$this->expectException(\DrdPlus\RollsOn\QualityAndSuccess\Exceptions\EverySuccessCodeShouldBeUnique::class);
$rollOnQuality = $this->createRollOnQuality(1);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_create_it_only_from_simple_rolls_on_success is not named in camelCase. Open
public function I_can_create_it_only_from_simple_rolls_on_success()
{
$this->expectException(\DrdPlus\RollsOn\QualityAndSuccess\Exceptions\ExpectedSimpleRollsOnSuccessOnly::class);
$rollOnQuality = $this->createRollOnQuality(123);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_use_it is not named in camelCase. Open
public function I_can_use_it(RollOnQuality $expectedRollOnQuality, array $simpleRollsOnSuccess, string $expectedResultCode, bool $expectingSuccess)
{
$extendedRollOnSuccessReflection = new \ReflectionClass(ExtendedRollOnSuccess::class);
/** @var ExtendedRollOnSuccess $extendedRollOnSuccess */
$extendedRollOnSuccess = $extendedRollOnSuccessReflection->newInstanceArgs($simpleRollsOnSuccess);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_use_only_unique_difficulties is not named in camelCase. Open
public function I_can_use_only_unique_difficulties()
{
$this->expectException(\DrdPlus\RollsOn\QualityAndSuccess\Exceptions\EveryDifficultyShouldBeUnique::class);
$rollOnQuality = $this->createRollOnQuality(123);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_use_non_unique_success_codes_if_no_success_happens_on_them is not named in camelCase. Open
public function I_can_use_non_unique_success_codes_if_no_success_happens_on_them()
{
$rollOnQuality = $this->createRollOnQuality(1);
$extendedRollOnSuccess = new ExtendedRollOnSuccess(
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}
Source
The method I_can_use_different_instances_with_same_values_of_rolls_on_quality is not named in camelCase. Open
public function I_can_use_different_instances_with_same_values_of_rolls_on_quality()
{
$firstRollOnQuality = $this->createRollOnQuality(1);
$similarRollOnQuality = $this->createRollOnQuality(1);
$extendedRollOnSuccess = new ExtendedRollOnSuccess(
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}