mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-17 15:31:27 +00:00
Loop control statements.
This commit is contained in:
parent
5d1185e9fb
commit
72b70fe094
@ -49,38 +49,35 @@ final class GildedRose
|
|||||||
public function updateQuality()
|
public function updateQuality()
|
||||||
{
|
{
|
||||||
foreach ($this->_items as $item) {
|
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->name != 'Aged Brie' && $item->name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if ($item->quality > 0) {
|
if ($item->quality > 0) {
|
||||||
if ($item->name != 'Sulfuras, Hand of Ragnaros') {
|
|
||||||
$item->quality--;
|
$item->quality--;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if ($item->quality < 50) {
|
if ($item->quality < 50) {
|
||||||
$item->quality = $item->quality++;
|
$item->quality++;
|
||||||
if ($item->name == 'Backstage passes to a TAFKAL80ETC concert') {
|
if ($item->name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if ($item->sell_in < 11) {
|
if ($item->sell_in <= 10) {
|
||||||
$item->quality += 2;
|
$item->quality += 2;
|
||||||
}
|
}
|
||||||
if ($item->sell_in < 6) {
|
if ($item->sell_in <= 5) {
|
||||||
$item->quality += 3;
|
$item->quality += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item->name != 'Sulfuras, Hand of Ragnaros') {
|
|
||||||
$item->sell_in--;
|
$item->sell_in--;
|
||||||
}
|
|
||||||
|
|
||||||
if ($item->sell_in < 0) {
|
if ($item->sell_in < 0) {
|
||||||
if ($item->name != 'Aged Brie') {
|
if ($item->name != 'Aged Brie') {
|
||||||
if ($item->name != 'Backstage passes to a TAFKAL80ETC concert') {
|
if ($item->name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if ($item->quality > 0) {
|
if ($item->quality > 0) {
|
||||||
if ($item->name != 'Sulfuras, Hand of Ragnaros') {
|
|
||||||
$item->quality -= 2;
|
$item->quality -= 2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$item->quality = 0;
|
$item->quality = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user