From b4a02d3f5e20353ee350d5f1536e028124e3a813 Mon Sep 17 00:00:00 2001 From: Pen-y-Fan <40126936+Pen-y-Fan@users.noreply.github.com> Date: Thu, 23 Jul 2020 22:49:59 +0100 Subject: [PATCH] Updated PHP version for PHP7.2+ Removed PHP5 (no longer supported) Renamed PHP7 to PHP - consistent with other kata Added the same helpers as other PHP Kata Updated the code to PHP7.2+ standard Didn't change GildedRose updateQuality method Updated GildedRoseTest (still failing) Added ApprovalTest (passing) - same text file as texttests / ThirtyDays / stdout.gr (only renamed). --- .../gilded_rose.php => php/src/GildedRose.php | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) rename php5/src/gilded_rose.php => php/src/GildedRose.php (81%) diff --git a/php5/src/gilded_rose.php b/php/src/GildedRose.php similarity index 81% rename from php5/src/gilded_rose.php rename to php/src/GildedRose.php index 5636901a..cfb7f78a 100644 --- a/php5/src/gilded_rose.php +++ b/php/src/GildedRose.php @@ -1,14 +1,23 @@ items = $items; } - function update_quality() { + public function updateQuality(): void + { foreach ($this->items as $item) { if ($item->name != 'Aged Brie' and $item->name != 'Backstage passes to a TAFKAL80ETC concert') { if ($item->quality > 0) { @@ -33,11 +42,11 @@ class GildedRose { } } } - + if ($item->name != 'Sulfuras, Hand of Ragnaros') { $item->sell_in = $item->sell_in - 1; } - + if ($item->sell_in < 0) { if ($item->name != 'Aged Brie') { if ($item->name != 'Backstage passes to a TAFKAL80ETC concert') { @@ -58,22 +67,3 @@ class GildedRose { } } } - -class Item { - - public $name; - public $sell_in; - public $quality; - - function __construct($name, $sell_in, $quality) { - $this->name = $name; - $this->sell_in = $sell_in; - $this->quality = $quality; - } - - public function __toString() { - return "{$this->name}, {$this->sell_in}, {$this->quality}"; - } - -} -