Skip to content

Commit

Permalink
Improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed May 28, 2024
1 parent 9956a71 commit a10a84c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/AbstractActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,8 @@ public function getOldPrimaryKey(bool $asArray = false): mixed
);
}

if (count($keys) === 1) {
$key = $this->oldAttributes[$keys[0]] ?? null;

return $asArray ? [$keys[0] => $key] : $key;
if ($asArray === false && count($keys) === 1) {
return $this->oldAttributes[reset($keys)] ?? null;
}

$values = [];
Expand All @@ -209,8 +207,8 @@ public function getPrimaryKey(bool $asArray = false): mixed
{
$keys = $this->primaryKey();

if (count($keys) === 1) {
return $asArray ? [$keys[0] => $this->getAttribute($keys[0])] : $this->getAttribute($keys[0]);
if ($asArray === false && count($keys) === 1) {
return $this->getAttribute(reset($keys));
}

$values = [];
Expand Down

0 comments on commit a10a84c

Please sign in to comment.