Merge pull request #6257 from yashodha/CRM-16854
[civicrm-core.git] / CRM / Core / Key.php
index b7ab0805aef61605d963d5c91c67cc6366ab489b..1eb478f91c05c9a7d2fb279b454cc0773397a38d 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -38,11 +38,10 @@ class CRM_Core_Key {
   static $_sessionID = NULL;
 
   /**
-   * Generate a private key per session and store in session
+   * Generate a private key per session and store in session.
    *
    * @return string
    *   private key for this session
-   * @static
    */
   public static function privateKey() {
     if (!self::$_key) {
@@ -81,12 +80,11 @@ class CRM_Core_Key {
    *
    * @return string
    *   valid formID
-   * @static
    */
   public static function get($name, $addSequence = FALSE) {
     $privateKey = self::privateKey();
-    $sessionID  = self::sessionID();
-    $key        = md5($sessionID . $name . $privateKey);
+    $sessionID = self::sessionID();
+    $key = md5($sessionID . $name . $privateKey);
 
     if ($addSequence) {
       // now generate a random number between 1 and 100K and add it to the key
@@ -97,7 +95,7 @@ class CRM_Core_Key {
   }
 
   /**
-   * Validate a form key based on the form name
+   * Validate a form key based on the form name.
    *
    * @param string $key
    * @param string $name
@@ -105,7 +103,6 @@ class CRM_Core_Key {
    *
    * @return string
    *   if valid, else null
-   * @static
    */
   public static function validate($key, $name, $addSequence = FALSE) {
     if (!is_string($key)) {
@@ -156,4 +153,5 @@ class CRM_Core_Key {
     // ensure that hash is a 32 digit hex number
     return preg_match('#[0-9a-f]{32}#i', $hash) ? TRUE : FALSE;
   }
+
 }