Last active
January 14, 2019 17:48
-
-
Save JavierCane/b50c300e029b11cef8ac to your computer and use it in GitHub Desktop.
Base for the GildedRose kata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class GildedRose { | |
public static function updateQuality( | |
$items | |
) { | |
for ($i = 0; $i < count($items); $i++) { | |
if (("Aged Brie" != $items[$i]->getName()) && ("Backstage passes to a TAFKAL80ETC concert" != $items[$i]->getName())) { | |
if ($items[$i]->getQuality() > 0) { | |
if ("Sulfuras, Hand of Ragnaros" != $items[$i]->getName()) { | |
$items[$i]->setQuality($items[$i]->getQuality() - 1); | |
} | |
} | |
} else { | |
if ($items[$i]->getQuality() < 50) { | |
$items[$i]->setQuality($items[$i]->getQuality() + 1); | |
if ("Backstage passes to a TAFKAL80ETC concert" == $items[$i]->getName()) { | |
if ($items[$i]->getSellIn() < 11) { | |
if ($items[$i]->getQuality() < 50) { | |
$items[$i]->setQuality($items[$i]->getQuality() + 1); | |
} | |
} | |
if ($items[$i]->getSellIn() < 6) { | |
if ($items[$i]->getQuality() < 50) { | |
$items[$i]->setQuality($items[$i]->getQuality() + 1); | |
} | |
} | |
} | |
} | |
} | |
if ("Sulfuras, Hand of Ragnaros" != $items[$i]->getName()) { | |
$items[$i]->setSellIn($items[$i]->getSellIn() - 1); | |
} | |
if ($items[$i]->getSellIn() < 0) { | |
if ("Aged Brie" != $items[$i]->getName()) { | |
if ("Backstage passes to a TAFKAL80ETC concert" != $items[$i]->getName()) { | |
if ($items[$i]->getQuality() > 0) { | |
if ("Sulfuras, Hand of Ragnaros" != $items[$i]->getName()) { | |
$items[$i]->setQuality($items[$i]->getQuality() - 1); | |
} | |
} | |
} else { | |
$items[$i]->setQuality($items[$i]->getQuality() - $items[$i]->getQuality()); | |
} | |
} else { | |
if ($items[$i]->getQuality() < 50) { | |
$items[$i]->setQuality($items[$i]->getQuality() + 1); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment