BetterFormatter::onFormatGroup()   B
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 13
nc 5
nop 1
1
<?php
2
3
use Noair\Event;
4
5
/**
6
 * An example Noair Observer
7
 *
8
 * This is an example Observer/plugin, which will override
9
 * previously called Observers. This example Observer enhances
10
 * the group and date formatting
11
 *
12
 * @author      Garrett Whitehorn
13
 * @author      David Tkachuk
14
 * @package     Noair
15
 * @subpackage  NoairExample
16
 * @version     1.0
17
 */
18
class BetterFormatter extends Noair\Observer
19
{
20
    public function onFormatGroup(Event $event) {
21
        $groupName = strtolower($event->data);
22
23
        switch ($groupName):
24
            case 'admin':
25
            case 'administrator':
26
                $groupName = '<span style="color:#F00;">Administrator</span>';
27
                break;
28
29
            case 'mod':
30
            case 'moderator':
31
                $groupName = '<span style="color:#00A;">Moderator</span>';
32
                break;
33
        endswitch;
34
35
        return $groupName;
36
    }
37
38
    public function onFormatDate(Event $event) {
39
        return date('F j, Y h:i:s A T', $event->data);
40
    }
41
}
42