mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 07:51:29 +00:00
function refactoring
This commit is contained in:
parent
4ad2a537ca
commit
4615681e68
@ -12,52 +12,50 @@ final class GildedRose {
|
|||||||
|
|
||||||
public function updateQuality() {
|
public function updateQuality() {
|
||||||
foreach ($this->items as $item) {
|
foreach ($this->items as $item) {
|
||||||
if ($item->name != 'Aged Brie' and $item->name != 'Backstage passes to a TAFKAL80ETC concert') {
|
if($item->name == 'Aged Brie'){
|
||||||
if ($item->quality > 0) {
|
$item->quality += 1;
|
||||||
if ($item->name != 'Sulfuras, Hand of Ragnaros') {
|
|
||||||
$item->quality = $item->quality - 1;
|
if ($item->sell_in <= 0) {
|
||||||
} else {
|
$item->quality += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($item->quality > 50) {
|
||||||
|
$item->quality = 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
$item->sell_in -= 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if($item->name == 'Backstage passes to a TAFKAL80ETC concert'){
|
||||||
|
$item->quality += 1;
|
||||||
|
if ($item->sell_in <= 10) {
|
||||||
|
$item->quality += 1;
|
||||||
|
}
|
||||||
|
if ($item->sell_in <= 5) {
|
||||||
|
$item->quality += 1;
|
||||||
|
}
|
||||||
|
if ($item->quality > 50) {
|
||||||
|
$item->quality = 50;
|
||||||
|
}
|
||||||
|
if ($item->sell_in <= 0) {
|
||||||
|
$item->quality = 0;
|
||||||
|
}
|
||||||
|
$item->sell_in -= 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if ($item->name == 'Sulfuras, Hand of Ragnaros') {
|
||||||
$item->quality = 80;
|
$item->quality = 80;
|
||||||
}
|
return;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($item->quality < 50) {
|
|
||||||
$item->quality = $item->quality + 1;
|
|
||||||
if ($item->name == 'Backstage passes to a TAFKAL80ETC concert') {
|
|
||||||
if ($item->sell_in < 11) {
|
|
||||||
if ($item->quality < 50) {
|
|
||||||
$item->quality = $item->quality + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($item->sell_in < 6) {
|
|
||||||
if ($item->quality < 50) {
|
|
||||||
$item->quality = $item->quality + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item->name != 'Sulfuras, Hand of Ragnaros') {
|
else {
|
||||||
$item->sell_in = $item->sell_in - 1;
|
$item->quality -= 1;
|
||||||
}
|
if ($item->sell_in <= 0) {
|
||||||
|
$item->quality -= 1;
|
||||||
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 = $item->quality - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$item->quality = $item->quality - $item->quality;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($item->quality < 50) {
|
|
||||||
$item->quality = $item->quality + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$item->sell_in -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user