Skip to content

Commit af0651c

Browse files
committed
Use elseif for checking Serializable after Document or PackedArray
Processing a Document and PackedArray will yield an array, so we can avoid a redundant Serializable check by using elseif.
1 parent 51d54ab commit af0651c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/functions.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ function document_to_array($document): array
121121
'document' => 'bson',
122122
'root' => 'array',
123123
]);
124-
}
125-
126-
if ($document instanceof Serializable) {
124+
} elseif ($document instanceof Serializable) {
127125
$document = $document->bsonSerialize();
128126
}
129127

@@ -244,9 +242,7 @@ function is_pipeline($pipeline): bool
244242
'document' => 'bson',
245243
'root' => 'array',
246244
]);
247-
}
248-
249-
if ($pipeline instanceof Serializable) {
245+
} elseif ($pipeline instanceof Serializable) {
250246
$pipeline = $pipeline->bsonSerialize();
251247
}
252248

0 commit comments

Comments
 (0)