From 5d1185e9fba12be9b27378c84d82b1ed0096ba85 Mon Sep 17 00:00:00 2001 From: Povilas Brilius Date: Fri, 1 May 2020 19:54:43 +0300 Subject: [PATCH] Structural sencentes - statements improvement. --- php7/src/GildedRose.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/php7/src/GildedRose.php b/php7/src/GildedRose.php index 134f1488..016e6fe9 100644 --- a/php7/src/GildedRose.php +++ b/php7/src/GildedRose.php @@ -49,32 +49,28 @@ final class GildedRose public function updateQuality() { foreach ($this->_items as $item) { - if ($item->name != 'Aged Brie' and $item->name != 'Backstage passes to a TAFKAL80ETC concert') { + 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 - 1; + $item->quality--; } } } else { if ($item->quality < 50) { - $item->quality = $item->quality + 1; + $item->quality = $item->quality++; if ($item->name == 'Backstage passes to a TAFKAL80ETC concert') { if ($item->sell_in < 11) { - if ($item->quality < 50) { - $item->quality = $item->quality + 2; - } + $item->quality += 2; } if ($item->sell_in < 6) { - if ($item->quality < 50) { - $item->quality = $item->quality + 3; - } + $item->quality += 3; } } } } if ($item->name != 'Sulfuras, Hand of Ragnaros') { - $item->sell_in = $item->sell_in - 1; + $item->sell_in--; } if ($item->sell_in < 0) { @@ -82,15 +78,15 @@ final class GildedRose if ($item->name != 'Backstage passes to a TAFKAL80ETC concert') { if ($item->quality > 0) { if ($item->name != 'Sulfuras, Hand of Ragnaros') { - $item->quality = $item->quality - 2; + $item->quality -= 2; } } } else { - $item->quality = $item->quality - $item->quality; + $item->quality = 0; } } else { if ($item->quality < 50) { - $item->quality = $item->quality + 1; + $item->quality++; } } }