PHP code example of prodigeris / php-gilded-rose-refactoring-kata

1. Go to this page and download the library: Download prodigeris/php-gilded-rose-refactoring-kata library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

prodigeris / php-gilded-rose-refactoring-kata example snippets




$sulfuras = new \GildedRose\Item('Sulfuras, Hand of Ragnaros', 80, 2);
$regularItem = new \GildedRose\Item('AK-47, Hand of Ragnaros', 10, 2);
$backstagePass = new \GildedRose\Item('Backstage passes to a TAFKAL80ETC concert', 10, 2);

$items = compact('sulfuras', 'regularItem', 'backstagePass');

$productFactoryRegistry = new \GildedRose\ProductFactoryRegistry();

$productFactoryRegistry->register(\GildedRose\Products\RegularProduct::class);
$productFactoryRegistry->register(\GildedRose\Products\Sulfuras::class);
$productFactoryRegistry->register(\GildedRose\Products\BackstagePass::class);

$productFactory = new \GildedRose\ProductFactory($productFactoryRegistry);

$gildedRose = new \GildedRose\GildedRose($items, $productFactory);
$gildedRose->updateQuality();



namespace GildedRose\Products;

use GildedRose\Product;

/**
 * Class Conjured
 *
 * @package \GildedRose\Products
 */
class Conjured extends Product
{
    /**
     * The name of the product
     */
    const NAME = 'Conjured Mana Cake';

    /**
     * Quality increases by 2 over time
     *
     * @var int
     */
    protected static $quality_step = -2;
}

$productFactoryRegistry->register(Conjured::class);