improve check in setters and add types in repositories

This commit is contained in:
2023-09-22 13:48:37 +02:00
parent e6e42777d7
commit 949c5424f0
3 changed files with 8 additions and 62 deletions

View File

@@ -507,12 +507,7 @@ class User implements UserInterface, \Stringable
public function setMainScope(?Scope $mainScope): User
{
$currentScopeUnchanged = array_filter(
$this->scopeHistories->toArray(),
fn($row) => $row->getEndDate() === null && $row->getScope() === $mainScope
);
if (count($currentScopeUnchanged) > 0) {
if ($mainScope === $this->getMainScope()) {
return $this;
}
@@ -572,12 +567,7 @@ class User implements UserInterface, \Stringable
public function setUserJob(?UserJob $userJob): User
{
$currentJobUnchanged = array_filter(
$this->jobHistories->toArray(),
fn($row) => $row->getEndDate() === null && $row->getJob() === $userJob
);
if (count($currentJobUnchanged) > 0) {
if ($userJob === $this->getUserJob()) {
return $this;
}