/ Gists / 3. Static Factory Method
On gists

3. Static Factory Method

Navrhove vzory - Bohmer

static-factory-method.php Raw #

<?php

class DebuggerFactory
{
    public static function createDebugger($type)
    {
        switch (strtolower($type)) {
            case 'log':
                return DebuggerLog::getInstance();
                break;
            case 'echo':
                return DebuggerEcho::getInstance();
                break;
            default:
                throw new UnknownDebuggerException();
        }
    }
}