parse number types and numbering plans
authorChristian Weiske <cweiske@cweiske.de>
Fri, 20 Jul 2012 21:06:03 +0000 (23:06 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Fri, 20 Jul 2012 21:06:03 +0000 (23:06 +0200)
src/callnotifier/EDSS1/Parameter/6C.php
src/callnotifier/EDSS1/Parameter/70.php
src/callnotifier/EDSS1/Parameter/INumber.php [new file with mode: 0644]
src/callnotifier/EDSS1/Parameter/Names.php [new file with mode: 0644]
src/callnotifier/Logger/Echo.php

index 2acdebd..cba4560 100644 (file)
@@ -5,6 +5,7 @@ namespace callnotifier;
  * Information element: Calling party number
  */
 class EDSS1_Parameter_6C extends EDSS1_Parameter
+    implements EDSS1_Parameter_INumber
 {
     public $title = 'Calling party number';
 
@@ -17,6 +18,9 @@ class EDSS1_Parameter_6C extends EDSS1_Parameter
     public function setData($data)
     {
         parent::setData($data);
+        $this->numberType    = (ord($data{0}) & 112) >> 4;
+        $this->numberingPlan = (ord($data{0}) & 15);
+        //data{1} is presentation/screening indicator
         $this->number = substr($data, 2);
     }
 }
index 0127d43..679e2eb 100644 (file)
@@ -5,6 +5,7 @@ namespace callnotifier;
  * Information element: Called party number
  */
 class EDSS1_Parameter_70 extends EDSS1_Parameter
+    implements EDSS1_Parameter_INumber
 {
     public $title = 'Called party number';
 
@@ -15,6 +16,8 @@ class EDSS1_Parameter_70 extends EDSS1_Parameter
     public function setData($data)
     {
         parent::setData($data);
+        $this->numberType    = (ord($data{0}) & 112) >> 4;
+        $this->numberingPlan = (ord($data{0}) & 15);
         $this->number = substr($data, 1);
     }
 
diff --git a/src/callnotifier/EDSS1/Parameter/INumber.php b/src/callnotifier/EDSS1/Parameter/INumber.php
new file mode 100644 (file)
index 0000000..d53594e
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+namespace callnotifier;
+
+/**
+ * Parameter that has a number
+ */
+interface EDSS1_Parameter_INumber
+{
+}
+?>
\ No newline at end of file
diff --git a/src/callnotifier/EDSS1/Parameter/Names.php b/src/callnotifier/EDSS1/Parameter/Names.php
new file mode 100644 (file)
index 0000000..cb6caef
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+namespace callnotifier;
+
+/**
+ * Static parameters to resolve names of types
+ */
+class EDSS1_Parameter_Names extends EDSS1_Parameter
+{
+    static $numberTypes = array(
+        0 => 'Unknown',
+        1 => 'International number',
+        2 => 'National number',
+        3 => 'Network specific number',
+        4 => 'Subscriber number',
+        5 => 'Abbreviated number',
+        6 => 'Reserved',
+    );
+
+    static $numberingPlans = array(
+         0 => 'Unknown',
+         1 => 'ISDN/Telephony',
+         3 => 'Data',
+         4 => 'Telex',
+         8 => 'National standard',
+         9 => 'Private',
+        15 => 'Reserved',
+    );
+
+}
+
+?>
index 688eaaf..c37e7b6 100644 (file)
@@ -62,6 +62,13 @@ class Logger_Echo implements Logger
                        : ''
                     )
                 );
+                if ($param instanceof EDSS1_Parameter_INumber) {
+                    echo sprintf(
+                        "    Number type: %s, plan: %s\n",
+                        EDSS1_Parameter_Names::$numberTypes[$param->numberType],
+                        EDSS1_Parameter_Names::$numberingPlans[$param->numberingPlan]
+                    );
+                }
             }
         } else {
             echo $this->blue . $type . $this->end . ': '