diff --git a/php7/src/BackstagePasses.php b/php7/src/BackstagePasses.php index 6a508d2e..bf4fec76 100644 --- a/php7/src/BackstagePasses.php +++ b/php7/src/BackstagePasses.php @@ -14,18 +14,23 @@ class BackstagePasses extends GildedRose public function updateQuality(){ $this->item->quality += 1; + if ($this->item->sell_in <= 10) { $this->item->quality += 1; } + if ($this->item->sell_in <= 5) { $this->item->quality += 1; } + if ($this->item->quality > 50) { $this->item->quality = 50; } + if ($this->item->sell_in <= 0) { $this->item->quality = 0; } + $this->item->sell_in -= 1; } } \ No newline at end of file diff --git a/php7/src/Conjured.php b/php7/src/Conjured.php index 965a85f8..20b8e2eb 100644 --- a/php7/src/Conjured.php +++ b/php7/src/Conjured.php @@ -11,6 +11,7 @@ class Conjured public function __construct($item) { $this->item = $item; } + public function updateQuality(){ $this->item->quality -= 2; diff --git a/php7/src/DefaultItem.php b/php7/src/DefaultItem.php index f932fdb2..c497e8d3 100644 --- a/php7/src/DefaultItem.php +++ b/php7/src/DefaultItem.php @@ -11,6 +11,7 @@ class DefaultItem extends GildedRose public function __construct($item) { $this->item = $item; } + public function updateQuality(){ $this->item->quality -= 1; diff --git a/php7/src/GildedRose.php b/php7/src/GildedRose.php index 2377c0d7..13b0f368 100644 --- a/php7/src/GildedRose.php +++ b/php7/src/GildedRose.php @@ -40,6 +40,7 @@ class GildedRose $sulfaras = new Sulfaras($item); $sulfaras->updateQuality(); break; + default: $defoultItem = new DefaultItem($item); $defoultItem->updateQuality(); diff --git a/php7/src/Sulfaras.php b/php7/src/Sulfaras.php index 7d7e1179..6732710b 100644 --- a/php7/src/Sulfaras.php +++ b/php7/src/Sulfaras.php @@ -12,6 +12,7 @@ class Sulfaras extends GildedRose public function __construct($item) { $this->item = $item; } + public function updateQuality(){ $this->item->quality = 80; } diff --git a/php7/test/GildedRoseTest.php b/php7/test/GildedRoseTest.php index dd5330ff..100e6d78 100644 --- a/php7/test/GildedRoseTest.php +++ b/php7/test/GildedRoseTest.php @@ -32,7 +32,7 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase $this->assertEquals($items[0]->sell_in, 0); } - public function test_backstage_then_quality_maximum_sell_in_lower_then_zero() + public function test_backstage_then_quality_maximum_sell_in_lower_than_zero() { $items = [new Item("Backstage passes to a TAFKAL80ETC concert", -5, 50)]; $gildedRose = new GildedRose($items); @@ -59,7 +59,7 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase $this->assertEquals($items[0]->sell_in, 6); } - public function test_backstage_then_quality_maximum_sell_in_greater_then_ten() + public function test_backstage_then_quality_maximum_sell_in_greater_than_ten() { $items = [new Item("Backstage passes to a TAFKAL80ETC concert", 11, 50)]; $gildedRose = new GildedRose($items); @@ -68,7 +68,7 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase $this->assertEquals($items[0]->sell_in, 10); } - public function test_backstage_then_sell_in_greater_then_ten() + public function test_backstage_then_sell_in_greater_than_ten() { $items = [new Item("Backstage passes to a TAFKAL80ETC concert", 11, 1)]; $gildedRose = new GildedRose($items); @@ -122,7 +122,7 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase $this->assertEquals($items[0]->sell_in, 0); } - public function test_sulfuras_then_sell_in_lower_then_zero() + public function test_sulfuras_then_sell_in_lower_than_zero() { $items = [new Item("Sulfuras, Hand of Ragnaros", -1, 10)]; $gildedRose = new GildedRose($items); @@ -131,7 +131,7 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase $this->assertEquals($items[0]->sell_in, -1); } - public function test_aged_brie_then_sell_in_greater_then_zero() + public function test_aged_brie_then_sell_in_greater_than_zero() { $items = [new Item("Aged Brie", 1, 1)]; $gildedRose = new GildedRose($items); @@ -140,7 +140,7 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase $this->assertEquals($items[0]->sell_in, 0); } - public function test_aged_brie_then_sell_in_lower_then_zero() + public function test_aged_brie_then_sell_in_lower_than_zero() { $items = [new Item("Aged Brie", -1, 1)]; $gildedRose = new GildedRose($items); @@ -167,7 +167,7 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase $this->assertEquals($items[0]->sell_in, 0); } - public function test_aged_brie_then_quality_maximum_and_sell_in_lower_then_zero() + public function test_aged_brie_then_quality_maximum_and_sell_in_lower_than_zero() { $items = [new Item("Aged Brie", -1, 50)]; $gildedRose = new GildedRose($items); @@ -176,7 +176,7 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase $this->assertEquals($items[0]->sell_in, -2); } - public function test_aged_brie_then_quality_maximum_and_sell_in_greater_then_zero() + public function test_aged_brie_then_quality_maximum_and_sell_in_greater_than_zero() { $items = [new Item("Aged Brie", 1, 50)]; $gildedRose = new GildedRose($items); @@ -194,7 +194,7 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase $this->assertEquals($items[0]->sell_in, 9); } - public function test_conjured_then_sell_in_greater_then_zero() + public function test_conjured_then_sell_in_greater_than_zero() { $items = [new Item("Conjured Mana Cake", 1, 5)]; $gildedRose = new GildedRose($items); @@ -203,7 +203,7 @@ class GildedRoseTest extends \PHPUnit\Framework\TestCase $this->assertEquals($items[0]->sell_in, 0); } - public function test_conjured_then_sell_in_lower_then_zero() + public function test_conjured_then_sell_in_lower_than_zero() { $items = [new Item("Conjured Mana Cake", -1, 5)]; $gildedRose = new GildedRose($items);