Skip to content

Commit aaab946

Browse files
committed
Fix #30073 - refactor nested if
1 parent 080a349 commit aaab946

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/code/Magento/Swatches/Model/Plugin/EavAttribute.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,16 @@ protected function processSwatchOptions(Attribute $attribute)
223223
*/
224224
protected function prepareOptionIds(array $optionsArray)
225225
{
226-
if (isset($optionsArray['value']) && is_array($optionsArray['value'])) {
227-
foreach (array_keys($optionsArray['value']) as $optionId) {
228-
if (isset($optionsArray['delete'][$optionId]) && $optionsArray['delete'][$optionId] == 1) {
229-
unset($optionsArray['value'][$optionId]);
230-
}
226+
if (!is_array($optionsArray['value'] ?? null)) {
227+
return $optionsArray;
228+
}
229+
230+
foreach (array_keys($optionsArray['value']) as $optionId) {
231+
if (isset($optionsArray['delete'][$optionId]) && (int)$optionsArray['delete'][$optionId] === 1) {
232+
unset($optionsArray['value'][$optionId]);
231233
}
232234
}
235+
233236
return $optionsArray;
234237
}
235238

0 commit comments

Comments
 (0)