The method getAnnouncements() has an NPath complexity of 472. The configured NPath complexity threshold is 200. Open
public function getAnnouncements(User $user, AccessUrl $url, string $iso): array
{
$qb = $this->getAnnouncementsQueryBuilder($iso, $url, $user);
$announcements = $qb->getQuery()->getResult();
- 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
Avoid using undefined variables such as '$conditions' which will lead to PHP notices. Open
$orX->addMultiple($conditions);
- 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 '$conditions' which will lead to PHP notices. Open
$conditions[] = $qb->expr()->like('s.roles', $qb->expr()->literal('%'.$role.'%'));
- 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 '$conditions' which will lead to PHP notices. Open
$conditions[] = $qb->expr()->like('s.roles', $qb->expr()->literal('%ROLE_ANONYMOUS%'));
- 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 method getAnnouncements uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$promotionList = $announcement->getCareer()->getPromotions();
}
- 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
Missing function doc comment Open
public function __construct(ManagerRegistry $registry, ParameterBagInterface $parameterBag, Security $security)
- Exclude checks
Missing function doc comment Open
public function getAnnouncementsQueryBuilder(string $iso, AccessUrl $url, ?User $user = null): QueryBuilder
- Exclude checks
Missing function doc comment Open
public function getVisibilityList(): array
- Exclude checks
Missing function doc comment Open
public function update(SysAnnouncement $sysAnnouncement, bool $andFlush = true): void
- Exclude checks
Missing function doc comment Open
public function addRoleListQueryBuilder(array $roles, ?QueryBuilder $qb = null): QueryBuilder
- Exclude checks
Missing function doc comment Open
public function delete(int $id): void
- Exclude checks
Add a single space around assignment operators Open
declare(strict_types=1);
- Exclude checks
Missing function doc comment Open
public function getAnnouncements(User $user, AccessUrl $url, string $iso): array
- Exclude checks
Missing function doc comment Open
public function addDateQueryBuilder(?QueryBuilder $qb = null): QueryBuilder
- Exclude checks
Missing class doc comment Open
class SysAnnouncementRepository extends ServiceEntityRepository
- Exclude checks