diff --git a/php/.buildpath b/php/.buildpath new file mode 100644 index 00000000..afc8dd1a --- /dev/null +++ b/php/.buildpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/php/.project b/php/.project new file mode 100644 index 00000000..48cd9855 --- /dev/null +++ b/php/.project @@ -0,0 +1,28 @@ + + + GildedRose.php + + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.dltk.core.scriptbuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.php.core.PHPNature + + diff --git a/php/.settings/com.piece_framework.makegood.core.prefs b/php/.settings/com.piece_framework.makegood.core.prefs new file mode 100644 index 00000000..894653fa --- /dev/null +++ b/php/.settings/com.piece_framework.makegood.core.prefs @@ -0,0 +1,10 @@ +cakephp_app_path= +cakephp_core_path= +ciunit_config_file= +ciunit_path= +eclipse.preferences.version=1 +phpunit_config_file=/GildedRose.php/phpunit.xml +preload_script= +test_file_pattern=.*test\\.php$ +test_folders=/GildedRose.php/test +testing_framework=PHPUnit diff --git a/php/.settings/org.eclipse.php.core.prefs b/php/.settings/org.eclipse.php.core.prefs new file mode 100644 index 00000000..b84a6057 --- /dev/null +++ b/php/.settings/org.eclipse.php.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +include_path=0;/GildedRose.php/test\u00050;/GildedRose.php/src\u00055;org.eclipse.dltk.USER_LIBRARY/PEAR diff --git a/php/.settings/org.eclipse.wst.common.project.facet.core.xml b/php/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 00000000..cd5af249 --- /dev/null +++ b/php/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/php/phpunit.xml b/php/phpunit.xml new file mode 100644 index 00000000..4c259412 --- /dev/null +++ b/php/phpunit.xml @@ -0,0 +1,15 @@ + + + + + + test + + + diff --git a/php/src/gilded_rose.php b/php/src/gilded_rose.php new file mode 100644 index 00000000..5636901a --- /dev/null +++ b/php/src/gilded_rose.php @@ -0,0 +1,79 @@ +items = $items; + } + + function update_quality() { + foreach ($this->items as $item) { + if ($item->name != 'Aged Brie' and $item->name != 'Backstage passes to a TAFKAL80ETC concert') { + if ($item->quality > 0) { + if ($item->name != 'Sulfuras, Hand of Ragnaros') { + $item->quality = $item->quality - 1; + } + } + } else { + if ($item->quality < 50) { + $item->quality = $item->quality + 1; + if ($item->name == 'Backstage passes to a TAFKAL80ETC concert') { + if ($item->sell_in < 11) { + if ($item->quality < 50) { + $item->quality = $item->quality + 1; + } + } + if ($item->sell_in < 6) { + if ($item->quality < 50) { + $item->quality = $item->quality + 1; + } + } + } + } + } + + 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') { + if ($item->quality > 0) { + if ($item->name != 'Sulfuras, Hand of Ragnaros') { + $item->quality = $item->quality - 1; + } + } + } else { + $item->quality = $item->quality - $item->quality; + } + } else { + if ($item->quality < 50) { + $item->quality = $item->quality + 1; + } + } + } + } + } +} + +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}"; + } + +} + diff --git a/php/test/bootstrap.php b/php/test/bootstrap.php new file mode 100644 index 00000000..57eddb69 --- /dev/null +++ b/php/test/bootstrap.php @@ -0,0 +1,2 @@ +update_quality(); + $this->assertEquals("fixme", $items[0]->name); + } + +}