chore: re-arrange cases

This commit is contained in:
EmanFateen 2025-11-23 00:17:33 +02:00
parent d80e4d5840
commit 4919bd0d67

View File

@ -21,27 +21,22 @@ final class GildedRose
if ($item->name === 'Sulfuras, Hand of Ragnaros') if ($item->name === 'Sulfuras, Hand of Ragnaros')
continue; continue;
$item->sellIn--;
if ($item->name === 'Aged Brie') { if ($item->name === 'Aged Brie') {
$item->quality = min(50, ++$item->quality); $item->quality = min(50, ++$item->quality);
} else if ($item->name === 'Backstage passes to a TAFKAL80ETC concert') { } else if ($item->name === 'Backstage passes to a TAFKAL80ETC concert') {
if ($item->sellIn <= 5) { if ($item->sellIn < 0) {
$updatedQuality = $item->quality + 3; $item->quality = 0;
$item->quality = min(50, $updatedQuality); } else if ($item->sellIn <= 5) {
$item->quality = min(50, $item->quality + 3);
} else if ($item->sellIn <= 10) { } else if ($item->sellIn <= 10) {
$updatedQuality = $item->quality + 2; $item->quality = min(50, $item->quality + 2);
$item->quality = min(50, $updatedQuality);
} }
} else { } else {
$updatedQuality = $item->quality - 2; $item->quality = max(0, $item->quality - 2);
$item->quality = max(0, $updatedQuality);
}
$item->sellIn--;
if ($item->sellIn < 0 && $item->name === 'Backstage passes to a TAFKAL80ETC concert')
$item->quality = 0;
} }
} }
}
} }