Skip to content

Commit

Permalink
Micro optimization related with cloning object
Browse files Browse the repository at this point in the history
  • Loading branch information
arogachev committed Sep 28, 2023
1 parent 11b289b commit 132c402
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/ItemsStorage.php
Expand Up @@ -431,12 +431,20 @@ private function createItem(
string|null $description = null,
string|null $ruleName = null,
): Permission|Role {
return $this
$item = $this
->createItemByTypeAndName($type, $name)
->withDescription($description ?? '')
->withRuleName($ruleName ?? null)
->withCreatedAt((int) $createdAt)
->withUpdatedAt((int) $updatedAt);

if ($description !== null) {
$item = $item->withDescription($description);
}

if ($ruleName !== null) {
$item = $item->withRuleName($ruleName);
}

return $item;
}

/**
Expand Down

0 comments on commit 132c402

Please sign in to comment.