mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 04:12:13 +00:00
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).
This commit is contained in:
parent
ed7a787e4f
commit
b4a02d3f5e
@ -1,14 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class GildedRose {
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace GildedRose;
|
||||||
|
|
||||||
|
final class GildedRose
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Item[]
|
||||||
|
*/
|
||||||
private $items;
|
private $items;
|
||||||
|
|
||||||
function __construct($items) {
|
public function __construct(array $items)
|
||||||
|
{
|
||||||
$this->items = $items;
|
$this->items = $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_quality() {
|
public function updateQuality(): void
|
||||||
|
{
|
||||||
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' and $item->name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if ($item->quality > 0) {
|
if ($item->quality > 0) {
|
||||||
@ -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}";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user