From 72b70fe094e12bb61b583f5d6978fb24d64b2ed4 Mon Sep 17 00:00:00 2001 From: Povilas Brilius Date: Fri, 1 May 2020 19:58:19 +0300 Subject: [PATCH] Loop control statements. --- php7/src/GildedRose.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/php7/src/GildedRose.php b/php7/src/GildedRose.php index 016e6fe9..575372c4 100644 --- a/php7/src/GildedRose.php +++ b/php7/src/GildedRose.php @@ -49,37 +49,34 @@ final class GildedRose public function updateQuality() { foreach ($this->_items as $item) { + if ($item->name === 'Sulfuras, Hand of Ragnaros') { + continue; + } if ($item->name != 'Aged Brie' && $item->name != 'Backstage passes to a TAFKAL80ETC concert') { if ($item->quality > 0) { - if ($item->name != 'Sulfuras, Hand of Ragnaros') { - $item->quality--; - } + $item->quality--; } } else { if ($item->quality < 50) { - $item->quality = $item->quality++; + $item->quality++; if ($item->name == 'Backstage passes to a TAFKAL80ETC concert') { - if ($item->sell_in < 11) { + if ($item->sell_in <= 10) { $item->quality += 2; } - if ($item->sell_in < 6) { + if ($item->sell_in <= 5) { $item->quality += 3; } } } } - if ($item->name != 'Sulfuras, Hand of Ragnaros') { - $item->sell_in--; - } + $item->sell_in--; if ($item->sell_in < 0) { if ($item->name != 'Aged Brie') { if ($item->name != 'Backstage passes to a TAFKAL80ETC concert') { if ($item->quality > 0) { - if ($item->name != 'Sulfuras, Hand of Ragnaros') { - $item->quality -= 2; - } + $item->quality -= 2; } } else { $item->quality = 0;