show names in CallEcho logger
[auerswald-callnotifier.git] / src / callnotifier / Logger / CallEcho.php
1 <?php
2 namespace callnotifier;
3
4 class Logger_CallEcho extends Logger_CallBase
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         $this->addUnsetVars($call);
22         echo 'Starting ' . $this->getTypeName($call)
23             . ' call from ' . trim($this->getNumberString($call, 'from'))
24             . ' to ' . trim($this->getNumberString($call, 'to')) . "\n";
25     }
26
27     protected function displayFinished(CallMonitor_Call $call)
28     {
29         $this->addUnsetVars($call);
30         echo 'Finished ' . $this->getTypeName($call)
31             . ' call from ' . trim($this->getNumberString($call, 'from'))
32             . ' to ' . trim($this->getNumberString($call, 'to'))
33             . ', length ' . date('H:i:s', $call->end - $call->start - 3600)
34             . "\n";
35     }
36
37     protected function getTypeName($call)
38     {
39         return $call->type == CallMonitor_Call::INCOMING
40             ? 'incoming' : 'outgoing';
41     }
42 }
43 ?>