all loggers support call type and MSN filtering now
[auerswald-callnotifier.git] / src / callnotifier / Logger / CallEcho.php
index 825bc2476a1cbf6465ad52010714a5553072a2b4..70fad4a4d99c7c788ee25045b7b92c336a179289 100644 (file)
@@ -1,33 +1,46 @@
 <?php
 namespace callnotifier;
 
-class Logger_CallEcho implements Logger
+class Logger_CallEcho extends Logger_CallBase
 {
     public function log($type, $arData)
     {
         switch ($type) {
         case 'startingCall':
-            $this->displayStart($arData['call']);
+            $displayMethod = 'displayStart';
             break;
         case 'finishedCall':
-            $this->displayFinished($arData['call']);
+            $displayMethod = 'displayFinished';
             break;
+        default:
+            return;
         }
+
+        $call = $arData['call'];
+        if (!$this->hasValidType($call)) {
+            return;
+        }
+        if (!$this->hasValidMsn($call)) {
+            return;
+        }
+        $this->$displayMethod($arData['call']);
     }
 
 
     protected function displayStart(CallMonitor_Call $call)
     {
+        $this->addUnsetVars($call);
         echo 'Starting ' . $this->getTypeName($call)
-            . ' call from ' . $call->from
-            . ' to ' . $call->to . "\n";
+            . ' call from ' . trim($this->getNumberString($call, 'from'))
+            . ' to ' . trim($this->getNumberString($call, 'to')) . "\n";
     }
 
     protected function displayFinished(CallMonitor_Call $call)
     {
+        $this->addUnsetVars($call);
         echo 'Finished ' . $this->getTypeName($call)
-            . ' call from ' . $call->from
-            . ' to ' . $call->to
+            . ' call from ' . trim($this->getNumberString($call, 'from'))
+            . ' to ' . trim($this->getNumberString($call, 'to'))
             . ', length ' . date('H:i:s', $call->end - $call->start - 3600)
             . "\n";
     }