chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Entity/AgendaReminder.php

Summary

Maintainability
A
0 mins
Test Coverage

The method encodeDateInterval uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->count = (int) $this->dateInterval->format('%a');
            $this->period = 'd';
        }

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

class AgendaReminder

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[ORM\JoinColumn(referencedColumnName: 'iid', nullable: false)]

Consider putting global function "getDateInterval" in a static class
Open

    public function getDateInterval(): DateInterval

Consider putting global function "getId" in a static class
Open

    public function getId(): ?int

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[ORM\ManyToOne(fetch: 'EAGER', inversedBy: 'reminders')]

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[ORM\Id]

Consider putting global function "__construct" in a static class
Open

    public function __construct()

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[ORM\Column(type: 'integer')]

Possible parse error: class missing opening or closing brace
Open

class AgendaReminder

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[ORM\GeneratedValue(strategy: 'AUTO')]

Possible parse error: class missing opening or closing brace
Open

class AgendaReminder

Missing function doc comment
Open

    public function setDateInterval(DateInterval $dateInterval): self

Consider putting global function "decodeDateInterval" in a static class
Open

    public function decodeDateInterval(): static

Scope keyword "static" must be followed by a single space
Open

    public function decodeDateInterval(): static

Space before opening parenthesis of function call prohibited
Open

        $this->dateInterval = match ($this->period) {

Scope keyword "static" must be followed by a single space
Open

    public function encodeDateInterval(): static

Consider putting global function "setDateInterval" in a static class
Open

    public function setDateInterval(DateInterval $dateInterval): self

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[ORM\Column(name: 'date_interval', type: 'dateinterval')]

Missing function doc comment
Open

    public function __construct()

Add a single space around assignment operators
Open

declare(strict_types=1);

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[Groups(['calendar_event:write', 'calendar_event:read'])]

Missing function doc comment
Open

    public function getDateInterval(): DateInterval

Missing function doc comment
Open

    public function setSent(bool $sent): self

Missing function doc comment
Open

    public function getEvent(): ?CCalendarEvent

Scope keyword "static" must be followed by a single space
Open

    public function setEvent(?CCalendarEvent $event): static

Case breaking statement indented incorrectly; expected 16 spaces, found 8
Open

        return $this;

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

#[ORM\Entity]

You must use "/**" style comments for a class comment
Open

class AgendaReminder

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[Groups(['calendar_event:write', 'calendar_event:read'])]

Missing function doc comment
Open

    public function getId(): ?int

Missing function doc comment
Open

    public function isSent(): bool

Missing function doc comment
Open

    public function setEvent(?CCalendarEvent $event): static

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[Groups(['calendar_event:read'])]

Consider putting global function "isSent" in a static class
Open

    public function isSent(): bool

Consider putting global function "setEvent" in a static class
Open

    public function setEvent(?CCalendarEvent $event): static

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

    #[ORM\Column(name: 'sent', type: 'boolean')]

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

#[ORM\Table(name: 'agenda_reminder')]

Consider putting global function "getEvent" in a static class
Open

    public function getEvent(): ?CCalendarEvent

Closing brace indented incorrectly; expected 4 spaces, found 0
Open

}

Consider putting global function "setSent" in a static class
Open

    public function setSent(bool $sent): self

Missing function doc comment
Open

    public function encodeDateInterval(): static

Missing function doc comment
Open

    public function decodeDateInterval(): static

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function getDateInterval(): DateInterval

Line indented incorrectly; expected 0 spaces, found 4
Open

    public int $count;

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 0 spaces, found 4
Open

    protected bool $sent;

Line indented incorrectly; expected 0 spaces, found 4
Open

    public string $period;

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function getId(): ?int

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function setDateInterval(DateInterval $dateInterval): self

Space before opening parenthesis of function call prohibited
Open

        $this->dateInterval = match ($this->period) {

Closing brace indented incorrectly; expected 4 spaces, found 0
Open

}

Line indented incorrectly; expected 0 spaces, found 4
Open

    protected ?int $id = null;

Line indented incorrectly; expected 0 spaces, found 4
Open

    private ?CCalendarEvent $event = null;

Line indented incorrectly; expected 4 spaces, found 12
Open

            default => null,

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function isSent(): bool

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function getEvent(): ?CCalendarEvent

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function __construct()

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function decodeDateInterval(): static

Line indented incorrectly; expected 0 spaces, found 4
Open

    protected DateInterval $dateInterval;

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function setEvent(?CCalendarEvent $event): static

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 0 spaces, found 4
Open

    }

Line indented incorrectly; expected 0 spaces, found 4
Open

    public function setSent(bool $sent): self

There are no issues that match your filters.

Category
Status