INFRA-132 - Batch #8
[civicrm-core.git] / CRM / Utils / Signer.php
index fb0d9a68762338c160fae856bdac36091b2daec1..1116cfbad181bd03478da873723d00dc4bc86ce3 100644 (file)
@@ -60,9 +60,9 @@ class CRM_Utils_Signer {
   /**
    * Instantiate a signature-processor
    *
-   * @param $secret
-   *   String, private.
-   * @param $paramNames
+   * @param string $secret
+   *   private.
+   * @param array $paramNames
    *   Array, fields which should be part of the signature.
    */
   public function __construct($secret, $paramNames) {
@@ -76,10 +76,10 @@ class CRM_Utils_Signer {
   /**
    * Generate a signature for a set of key-value pairs
    *
-   * @param $params
+   * @param array $params
    *   Array, key-value pairs.
-   * @param $salt
-   *   String, the salt (if known) or NULL (for auto-generated).
+   * @param string $salt
+   *   the salt (if known) or NULL (for auto-generated).
    * @return string, the full public token representing the signature
    */
   public function sign($params, $salt = NULL) {
@@ -88,8 +88,9 @@ class CRM_Utils_Signer {
     $message['payload'] = array();
     if (empty($salt)) {
       $message['salt'] = $this->createSalt();
-    } else {
-      $message['salt'] =  $salt;
+    }
+    else {
+      $message['salt'] = $salt;
     }
     // recall: paramNames is pre-sorted for stability
     foreach ($this->paramNames as $paramName) {
@@ -97,11 +98,12 @@ class CRM_Utils_Signer {
         if (is_numeric($params[$paramName])) {
           $params[$paramName] = (string) $params[$paramName];
         }
-      } else { // $paramName is not included or ===NULL
-        $params[$paramName] = '';
       }
-        $message['payload'][$paramName] = $params[$paramName];
+      else {// $paramName is not included or ===NULL
+        $params[$paramName] = '';
       }
+      $message['payload'][$paramName] = $params[$paramName];
+    }
     $token = $message['salt'] . $this->signDelim . md5(serialize($message));
     return $token;
   }
@@ -109,9 +111,9 @@ class CRM_Utils_Signer {
   /**
    * Determine whether a token represents a proper signature for $params
    *
-   * @param $token
-   *   String, the full public token representing the signature.
-   * @param $params
+   * @param string $token
+   *   the full public token representing the signature.
+   * @param array $params
    *   Array, key-value pairs.
    *
    * @throws Exception