BetterFormatter   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B onFormatGroup() 0 17 5
A onFormatDate() 0 3 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