src/CoreBundle/Entity/AgendaReminder.php
The method encodeDateInterval uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
Open
} else {
$this->count = (int) $this->dateInterval->format('%a');
$this->period = 'd';
}
- 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
Possible parse error: class missing opening or closing brace Open
Open
class AgendaReminder
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[ORM\JoinColumn(referencedColumnName: 'iid', nullable: false)]
- Exclude checks
Consider putting global function "getDateInterval" in a static class Open
Open
public function getDateInterval(): DateInterval
- Exclude checks
Consider putting global function "getId" in a static class Open
Open
public function getId(): ?int
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[ORM\ManyToOne(fetch: 'EAGER', inversedBy: 'reminders')]
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[ORM\Id]
- Exclude checks
Consider putting global function "__construct" in a static class Open
Open
public function __construct()
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[ORM\Column(type: 'integer')]
- Exclude checks
Possible parse error: class missing opening or closing brace Open
Open
class AgendaReminder
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[ORM\GeneratedValue(strategy: 'AUTO')]
- Exclude checks
Possible parse error: class missing opening or closing brace Open
Open
class AgendaReminder
- Exclude checks
Missing function doc comment Open
Open
public function setDateInterval(DateInterval $dateInterval): self
- Exclude checks
Consider putting global function "decodeDateInterval" in a static class Open
Open
public function decodeDateInterval(): static
- Exclude checks
Scope keyword "static" must be followed by a single space Open
Open
public function decodeDateInterval(): static
- Exclude checks
Space before opening parenthesis of function call prohibited Open
Open
$this->dateInterval = match ($this->period) {
- Exclude checks
Scope keyword "static" must be followed by a single space Open
Open
public function encodeDateInterval(): static
- Exclude checks
Consider putting global function "setDateInterval" in a static class Open
Open
public function setDateInterval(DateInterval $dateInterval): self
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[ORM\Column(name: 'date_interval', type: 'dateinterval')]
- Exclude checks
Missing function doc comment Open
Open
public function __construct()
- Exclude checks
Add a single space around assignment operators Open
Open
declare(strict_types=1);
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[Groups(['calendar_event:write', 'calendar_event:read'])]
- Exclude checks
Missing function doc comment Open
Open
public function getDateInterval(): DateInterval
- Exclude checks
Missing function doc comment Open
Open
public function setSent(bool $sent): self
- Exclude checks
Missing function doc comment Open
Open
public function getEvent(): ?CCalendarEvent
- Exclude checks
Scope keyword "static" must be followed by a single space Open
Open
public function setEvent(?CCalendarEvent $event): static
- Exclude checks
Case breaking statement indented incorrectly; expected 16 spaces, found 8 Open
Open
return $this;
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[ORM\Entity]
- Exclude checks
You must use "/**" style comments for a class comment Open
Open
class AgendaReminder
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[Groups(['calendar_event:write', 'calendar_event:read'])]
- Exclude checks
Missing function doc comment Open
Open
public function getId(): ?int
- Exclude checks
Missing function doc comment Open
Open
public function isSent(): bool
- Exclude checks
Missing function doc comment Open
Open
public function setEvent(?CCalendarEvent $event): static
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[Groups(['calendar_event:read'])]
- Exclude checks
Consider putting global function "isSent" in a static class Open
Open
public function isSent(): bool
- Exclude checks
Consider putting global function "setEvent" in a static class Open
Open
public function setEvent(?CCalendarEvent $event): static
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[ORM\Column(name: 'sent', type: 'boolean')]
- Exclude checks
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. Open
Open
#[ORM\Table(name: 'agenda_reminder')]
- Exclude checks
Consider putting global function "getEvent" in a static class Open
Open
public function getEvent(): ?CCalendarEvent
- Exclude checks
Closing brace indented incorrectly; expected 4 spaces, found 0 Open
Open
}
- Exclude checks
Consider putting global function "setSent" in a static class Open
Open
public function setSent(bool $sent): self
- Exclude checks
Missing function doc comment Open
Open
public function encodeDateInterval(): static
- Exclude checks
Missing function doc comment Open
Open
public function decodeDateInterval(): static
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public function getDateInterval(): DateInterval
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public int $count;
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
protected bool $sent;
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public string $period;
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public function getId(): ?int
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public function setDateInterval(DateInterval $dateInterval): self
- Exclude checks
Space before opening parenthesis of function call prohibited Open
Open
$this->dateInterval = match ($this->period) {
- Exclude checks
Closing brace indented incorrectly; expected 4 spaces, found 0 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
protected ?int $id = null;
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
private ?CCalendarEvent $event = null;
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 12 Open
Open
default => null,
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public function isSent(): bool
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public function getEvent(): ?CCalendarEvent
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public function __construct()
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public function decodeDateInterval(): static
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
protected DateInterval $dateInterval;
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public function setEvent(?CCalendarEvent $event): static
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
}
- Exclude checks
Line indented incorrectly; expected 0 spaces, found 4 Open
Open
public function setSent(bool $sent): self
- Exclude checks