diff --git a/php/README.md b/php/README.md index d67cfec1..0580b4a1 100644 --- a/php/README.md +++ b/php/README.md @@ -133,4 +133,4 @@ PHPUnit `composer phpstan` can be run: ps ``` -## ffff + diff --git a/php/fixtures/texttest_fixture.php b/php/fixtures/texttest_fixture.php index c8d13c20..0191b1a0 100644 --- a/php/fixtures/texttest_fixture.php +++ b/php/fixtures/texttest_fixture.php @@ -18,7 +18,6 @@ $items = [ new Item('Backstage passes to a TAFKAL80ETC concert', 15, 20), new Item('Backstage passes to a TAFKAL80ETC concert', 10, 49), new Item('Backstage passes to a TAFKAL80ETC concert', 5, 49), - // this conjured item does not work properly yet new Item('Conjured Mana Cake', 3, 6), ]; diff --git a/php/src/GildedRose.php b/php/src/GildedRose.php index 8af38a51..760147cf 100644 --- a/php/src/GildedRose.php +++ b/php/src/GildedRose.php @@ -1,47 +1,5 @@ name === 'Backstage passes to a TAFKAL80ETC concert') { if ($item->sell_in <= 10 && $item->sell_in > 5) { $this->increaseQuality($item, 1); - } - elseif ($item->sell_in <= 5) { + } elseif ($item->sell_in <= 5) { $this->increaseQuality($item, 2); } } @@ -88,21 +45,17 @@ final class GildedRose if ($item->quality < 50) { $this->increaseQuality($item, 1); } - } else { - if ($item->name === 'Backstage passes to a TAFKAL80ETC concert') { - $this->lowerQuality($item, $item->quality); - } else { - if ($item->quality > 0) { - $this->lowerQuality($item, 1); - } - } + } else if ($item->name === 'Backstage passes to a TAFKAL80ETC concert') { + $this->lowerQuality($item, $item->quality); + } else if ($item->quality > 0) { + $this->lowerQuality($item, 1); } } - $this->lowerSellIn($item, 1); + $this->lowerSellIn($item); } } - private function lowerQuality(Item $item, int $amount) + private function lowerQuality(Item $item, int $amount): void { if ($item->quality - $amount > 0) { $item->quality -= $amount; @@ -111,7 +64,7 @@ final class GildedRose } } - private function increaseQuality(Item $item, int $amount) + private function increaseQuality(Item $item, int $amount): void { if ($item->quality + $amount <= 50) { $item->quality += $amount; @@ -120,8 +73,8 @@ final class GildedRose } } - private function lowerSellIn(Item $item, int $amount) + private function lowerSellIn(Item $item): void { - $item->sell_in -= $amount; + $item->sell_in -= 1; } } \ No newline at end of file diff --git a/php/tests/approvals/ApprovalTest.testTestFixture.approved.txt b/php/tests/approvals/ApprovalTest.testTestFixture.approved.txt index a04e48ac..4e7237ff 100644 --- a/php/tests/approvals/ApprovalTest.testTestFixture.approved.txt +++ b/php/tests/approvals/ApprovalTest.testTestFixture.approved.txt @@ -21,7 +21,7 @@ Sulfuras, Hand of Ragnaros, -1, 80 Backstage passes to a TAFKAL80ETC concert, 14, 21 Backstage passes to a TAFKAL80ETC concert, 9, 50 Backstage passes to a TAFKAL80ETC concert, 4, 50 -Conjured Mana Cake, 2, 5 +Conjured Mana Cake, 2, 4 -------- day 2 -------- name, sellIn, quality @@ -33,7 +33,7 @@ Sulfuras, Hand of Ragnaros, -1, 80 Backstage passes to a TAFKAL80ETC concert, 13, 22 Backstage passes to a TAFKAL80ETC concert, 8, 50 Backstage passes to a TAFKAL80ETC concert, 3, 50 -Conjured Mana Cake, 1, 4 +Conjured Mana Cake, 1, 2 -------- day 3 -------- name, sellIn, quality @@ -45,7 +45,7 @@ Sulfuras, Hand of Ragnaros, -1, 80 Backstage passes to a TAFKAL80ETC concert, 12, 23 Backstage passes to a TAFKAL80ETC concert, 7, 50 Backstage passes to a TAFKAL80ETC concert, 2, 50 -Conjured Mana Cake, 0, 3 +Conjured Mana Cake, 0, 0 -------- day 4 -------- name, sellIn, quality @@ -57,7 +57,7 @@ Sulfuras, Hand of Ragnaros, -1, 80 Backstage passes to a TAFKAL80ETC concert, 11, 24 Backstage passes to a TAFKAL80ETC concert, 6, 50 Backstage passes to a TAFKAL80ETC concert, 1, 50 -Conjured Mana Cake, -1, 1 +Conjured Mana Cake, -1, 0 -------- day 5 -------- name, sellIn, quality