Skip to content

Commit

Permalink
Apply rector changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelien committed Mar 3, 2023
1 parent 2ddd559 commit 0c4391a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
40 changes: 17 additions & 23 deletions src/Entity/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ class Mapper
{
#[ORM\Id]
#[ORM\Column(type: 'integer')]
private $id;
private ?int $id = null;

#[ORM\Column(type: 'string', length: 255)]
private $display_name;
private ?string $display_name = null;

#[ORM\Column(type: 'datetime')]
private $account_created;
private ?\DateTimeInterface $account_created = null;

#[ORM\Column(type: 'integer')]
private $changesets_count;
private ?int $changesets_count = null;

#[ORM\Column(type: 'string', length: 255)]
private $status;
private ?string $status = null;

#[ORM\OneToMany(targetEntity: Changeset::class, mappedBy: 'mapper', orphanRemoval: true)]
private $changesets;
private Collection $changesets;

#[ORM\Column(type: 'text', nullable: true)]
private $image;
private ?string $image = null;

#[ORM\OneToMany(targetEntity: Note::class, mappedBy: 'mapper', orphanRemoval: true)]
private $notes;
private Collection $notes;

#[ORM\OneToOne(targetEntity: Welcome::class, mappedBy: 'mapper', cascade: ['persist'])]
private $welcome;
private ?Welcome $welcome = null;

#[ORM\ManyToMany(targetEntity: Region::class, inversedBy: 'mappers')]
private Collection $region;
Expand Down Expand Up @@ -128,11 +128,9 @@ public function addChangeset(Changeset $changeset): self

public function removeChangeset(Changeset $changeset): self
{
if ($this->changesets->removeElement($changeset)) {
// set the owning side to null (unless already changed)
if ($changeset->getMapper() === $this) {
$changeset->setMapper(null);
}
// set the owning side to null (unless already changed)
if ($this->changesets->removeElement($changeset) && $changeset->getMapper() === $this) {
$changeset->setMapper(null);
}

return $this;
Expand Down Expand Up @@ -170,23 +168,19 @@ public function addNote(Note $note): self

public function removeNote(Note $note): self
{
if ($this->notes->removeElement($note)) {
// set the owning side to null (unless already changed)
if ($note->getMapper() === $this) {
$note->setMapper(null);
}
// set the owning side to null (unless already changed)
if ($this->notes->removeElement($note) && $note->getMapper() === $this) {
$note->setMapper(null);
}

return $this;
}

public function getFirstChangeset(): Changeset
{
/** @var Changeset[] */
$changesets = $this->getChangesets()->toArray();
$changesets = $this->changesets->toArray();

/** @var \DateTimeImmutable[] */
$createdAt = array_map(fn (Changeset $changeset): ?\DateTimeImmutable => $changeset->getCreatedAt(), $changesets);
$createdAt = array_map(static fn (Changeset $changeset): ?\DateTimeImmutable => $changeset->getCreatedAt(), $changesets);

array_multisort($createdAt, \SORT_ASC, $changesets);

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Region.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Region
private ?string $id = null;

#[ORM\Column(type: 'datetime')]
private $lastUpdate;
private \DateTime $lastUpdate;

#[ORM\ManyToMany(targetEntity: Mapper::class, mappedBy: 'region')]
private Collection $mappers;
Expand Down

0 comments on commit 0c4391a

Please sign in to comment.