mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-14 06:01:39 +00:00
chore: remove nested if condition
This commit is contained in:
parent
99de845aa5
commit
d80e4d5840
@ -18,14 +18,14 @@ final class GildedRose
|
|||||||
public function updateQuality(): void
|
public function updateQuality(): void
|
||||||
{
|
{
|
||||||
foreach ($this->items as $item) {
|
foreach ($this->items as $item) {
|
||||||
if ($item->name === 'Sulfuras, Hand of Ragnaros') {
|
if ($item->name === 'Sulfuras, Hand of Ragnaros')
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
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 < 6) {
|
if ($item->sellIn <= 5) {
|
||||||
$updatedQuality = $item->quality + 3;
|
$updatedQuality = $item->quality + 3;
|
||||||
$item->quality = min(50, $updatedQuality);
|
$item->quality = min(50, $updatedQuality);
|
||||||
} else if ($item->sellIn <= 10) {
|
} else if ($item->sellIn <= 10) {
|
||||||
@ -39,10 +39,9 @@ final class GildedRose
|
|||||||
|
|
||||||
$item->sellIn--;
|
$item->sellIn--;
|
||||||
|
|
||||||
if ($item->sellIn < 0) {
|
if ($item->sellIn < 0 && $item->name === 'Backstage passes to a TAFKAL80ETC concert')
|
||||||
if ($item->name === 'Backstage passes to a TAFKAL80ETC concert')
|
$item->quality = 0;
|
||||||
$item->quality = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user