introduce UserInterface class, add simple parameter support for web and cli
[bdrem.git] / src / bdrem / Renderer / Console.php
1 <?php
2 namespace bdrem;
3
4 class Renderer_Console
5 {
6     public function render($arEvents)
7     {
8         $tbl = new \Console_Table(
9             CONSOLE_TABLE_ALIGN_LEFT,
10             array('sect' => '', 'rule' => '-', 'vert' => '')
11         );
12         $tbl->setAlign(0, CONSOLE_TABLE_ALIGN_RIGHT);
13         $tbl->setAlign(1, CONSOLE_TABLE_ALIGN_RIGHT);
14
15         $tbl->setHeaders(
16             array('Days', 'Age', 'Name', 'Event', 'Date', 'Day')
17         );
18
19         foreach ($arEvents as $event) {
20             $tbl->addRow(
21                 array(
22                     $event->days,
23                     $event->age,
24                     wordwrap($event->title, 30, "\n", true),
25                     wordwrap($event->type, 20, "\n", true),
26                     $event->date,
27                     strftime('%a', strtotime($event->localDate))
28                 )
29             );
30         }
31         return $tbl->getTable();
32     }
33 }
34 ?>