international numbers have a +
[auerswald-callnotifier.git] / src / callnotifier / Logger / CallEcho.php
1 <?php
2 namespace callnotifier;
3
4 class Logger_CallEcho implements Logger
5 {
6     public function log($type, $arData)
7     {
8         switch ($type) {
9         case 'startingCall':
10             $this->displayStart($arData['call']);
11             break;
12         case 'finishedCall':
13             $this->displayFinished($arData['call']);
14             break;
15         }
16     }
17
18
19     protected function displayStart(CallMonitor_Call $call)
20     {
21         echo 'Starting ' . $this->getTypeName($call)
22             . ' call from ' . $call->from
23             . ' to ' . $call->to . "\n";
24     }
25
26     protected function displayFinished(CallMonitor_Call $call)
27     {
28         echo 'Finished ' . $this->getTypeName($call)
29             . ' call from ' . $call->from
30             . ' to ' . $call->to
31             . ', length ' . date('H:i:s', $call->end - $call->start - 3600)
32             . "\n";
33     }
34
35     protected function getTypeName($call)
36     {
37         return $call->type == CallMonitor_Call::INCOMING
38             ? 'incoming' : 'outgoing';
39     }
40 }
41 ?>