The method fixItemProperty() has an NPath complexity of 4616. The configured NPath complexity threshold is 200. Open
public function fixItemProperty(
$tool,
ResourceRepository $repo,
$course,
$admin,
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method addSettingCurrent has 13 parameters. Consider reducing the number of parameters to less than 10. Open
public function addSettingCurrent(
$variable,
$subKey,
$type,
$category,
- Exclude checks
The class AbstractMigrationChamilo has a coupling between objects value of 24. Consider to reduce the number of dependencies under 13. Open
abstract class AbstractMigrationChamilo extends AbstractMigration
{
public const BATCH_SIZE = 20;
protected ?EntityManagerInterface $entityManager = null;
- 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
Avoid assigning values to variables in if clauses and the like (line '302', column '27'). Open
public function fixItemProperty(
$tool,
ResourceRepository $repo,
$course,
$admin,
- Read upRead up
- Exclude checks
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
The method getMailConfigurationValueFromFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$selectedValue = (string) $settingValue;
}
- 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
The method fixItemProperty uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$group = $groupList[$groupId] = $groupRepo->find($groupId);
}
- 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
The method addSettingCurrent uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$option['text'] = 'No';
}
- 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
The method fixItemProperty uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$lastUpdatedAt = new DateTime($item['lastedit_date'], new DateTimeZone('UTC'));
}
- 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
The method fixItemProperty uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$session = $sessionList[$sessionId] = $sessionRepo->find($sessionId);
}
- 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 unused parameters such as '$variable'. Open
public function removeSettingCurrent($variable): void
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused local variables such as '$rootPath'. Open
$rootPath = $this->container->get('kernel')->getProjectDir();
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Avoid unused parameters such as '$description'. Open
$description = ''
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Missing function doc comment Open
public function setEntityManager(EntityManagerInterface $entityManager): void
- Exclude checks
Variable "platform_email" is not in valid camel caps format Open
$platform_email = $configuration;
- Exclude checks
Missing function doc comment Open
public function getMailConfigurationValueFromFile(string $variable): ?string
- Exclude checks
Variable "platform_email" is not in valid camel caps format Open
global $platform_email;
- Exclude checks
Missing class doc comment Open
abstract class AbstractMigrationChamilo extends AbstractMigration
- Exclude checks
Declare public methods first,then protected ones and finally private ones Open
protected function writeFile(string $filename, string $content): void
- Exclude checks
Missing function doc comment Open
public function __construct(Connection $connection, LoggerInterface $logger)
- Exclude checks
Missing function doc comment Open
public function getMailConfigurationValue(string $variable, array $configuration = []): mixed
- Exclude checks
Variable "platform_email" is not in valid camel caps format Open
global $platform_email;
- Exclude checks
Variable "platform_email" is not in valid camel caps format Open
if (isset($platform_email[$variable])) {
- Exclude checks
Missing function doc comment Open
public function fileExists($filePath): bool
- Exclude checks
Missing function doc comment Open
public function getAdmin(): User
- Exclude checks
Missing function doc comment Open
public function fixItemProperty(
- Exclude checks
Missing function doc comment Open
public function findCourse(int $id): ?Course
- Exclude checks
Variable "platform_email" is not in valid camel caps format Open
$settingValue = $this->getConfigurationValue($variable, $platform_email);
- Exclude checks
Missing function doc comment Open
public function addLegacyFileToResource(
- Exclude checks
Add a single space around assignment operators Open
declare(strict_types=1);
- Exclude checks
Missing function doc comment Open
public function setContainer(?ContainerInterface $container = null): void
- Exclude checks
Missing function doc comment Open
public function findSession(int $id): ?Session
- Exclude checks
Declare public methods first,then protected ones and finally private ones Open
public function setEntityManager(EntityManagerInterface $entityManager): void
- Exclude checks
Missing function doc comment Open
public function adminExist(): bool
- Exclude checks
Variable "platform_email" is not in valid camel caps format Open
return $platform_email[$variable];
- Exclude checks
The variable $_configuration is not named in camelCase. Open
public function getConfigurationValue($variable, $configuration = null)
{
global $_configuration;
if (isset($configuration)) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $platform_email is not named in camelCase. Open
public function getMailConfigurationValueFromFile(string $variable): ?string
{
global $platform_email;
$rootPath = $this->container->get('kernel')->getProjectDir();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $platform_email is not named in camelCase. Open
public function getMailConfigurationValue(string $variable, array $configuration = []): mixed
{
global $platform_email;
if ($configuration) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $platform_email is not named in camelCase. Open
public function getMailConfigurationValue(string $variable, array $configuration = []): mixed
{
global $platform_email;
if ($configuration) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $platform_email is not named in camelCase. Open
public function getMailConfigurationValue(string $variable, array $configuration = []): mixed
{
global $platform_email;
if ($configuration) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $platform_email is not named in camelCase. Open
public function getMailConfigurationValueFromFile(string $variable): ?string
{
global $platform_email;
$rootPath = $this->container->get('kernel')->getProjectDir();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_configuration is not named in camelCase. Open
public function getConfigurationValue($variable, $configuration = null)
{
global $_configuration;
if (isset($configuration)) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $platform_email is not named in camelCase. Open
public function getMailConfigurationValue(string $variable, array $configuration = []): mixed
{
global $platform_email;
if ($configuration) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_configuration is not named in camelCase. Open
public function getConfigurationValue($variable, $configuration = null)
{
global $_configuration;
if (isset($configuration)) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_configuration is not named in camelCase. Open
public function getConfigurationValue($variable, $configuration = null)
{
global $_configuration;
if (isset($configuration)) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}