CSI: PHP

"Looking at your tweets I cannot even fathom what your job is. CSI:PHP?" — @grmpyprogrammer

Not Confusing Enough

| Comments

No, go ahead, add a little more abstraction. Don’t mind me, I’m just trying to maintain it is all.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

class core_output
{

    static public function factory($output_engine, $module)
    {
        switch ($output_engine) {

            case 'smarty':
                $file = OUT_SMARTY;
                break;
            default:

                $file = OUT_SMARTY;

                break;
        }

        if (include($file)) {
            $class = 'core_output_' . $output_engine;
            if (class_exists($class)) {
                $presenter = new $class($module);
                if ($presenter instanceof core_output_common) {
                    return $presenter;
                }

                echo 'Invalid presentation class: ' . $output_engine;
            }

            echo 'Presentation class not found: ' . $output_engine;
        }

        echo 'Presenter file not found: ' . $output_engine;
    }

//end factory
}

Comments