CSI: PHP

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

Go Ahead. Maintain This One. I Dare You.

| Comments

Page titles are stored in a numerically indexed session array. There are 22 cases in the switch statement and no default case. The style_inc property sometimes contains javascript, but not always.

Go ahead. Maintain this one. I dare you. I double-dog dare you.

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
<?php

class Page
{
    // . . .

    function set_style_title($page, $i)
    {
        switch ($page) {
            case 'home':
                $this->title = $_SESSION['content_title'][$i];
                $this->style_inc = '<link href="media/style/common.css" type="text/css" rel="stylesheet"></link>
                                    <link href="media/style/home.css" type="text/css" rel="stylesheet"></link>';
                break;
            case 'lost_pass':
                $this->title = $_SESSION['content_title'][$i];
                $this->style_inc = '<link href="media/style/common.css" type="text/css" rel="stylesheet"></link>
                                    <link href="media/style/lost.css" type="text/css" rel="stylesheet"></link>';
                break;
            case 'intro':
                $this->title = $_SESSION['content_title'][$i];
                $this->style_inc = '<link href="media/style/common.css" type="text/css" rel="stylesheet"></link>
                                    <link href="media/style/intro.css" type="text/css" rel="stylesheet"></link>';
                break;

            // . . . 19 more cases, but no default case . . .
        }
    }

    // . . .
}

Comments