Author: david
Date: Tue Jul 19 16:23:32 2011
New Revision: 9335

Log:
Simplify constructor

Modified:
   trunk/lib/QubitAsset.class.php

Modified: trunk/lib/QubitAsset.class.php
==============================================================================
--- trunk/lib/QubitAsset.class.php      Tue Jul 19 16:02:00 2011        (r9334)
+++ trunk/lib/QubitAsset.class.php      Tue Jul 19 16:23:32 2011        (r9335)
@@ -37,21 +37,7 @@
   {
     $this->name = $assetName;
     $this->contents = $assetContents;
-
-    if (isset($options['checksumAlgorithm']))
-    {
-      $this->setChecksumAlgorithm($options['checksumAlgorithm']);
-    }
-
-    // Only allow user to set checksum if an algorithm is specified
-    if (isset($options['checksum']) && isset($this->checksumAlgorithm))
-    {
-      $this->checksum = $options['checksum'];
-    }
-    else
-    {
-      $this->generateChecksum();
-    }
+    $this->generateChecksum('md5');
   }
 
   public function setName($value)
@@ -112,17 +98,24 @@
     return $this->checksumAlgorithm;
   }
 
-  public function generateChecksum()
+  public function generateChecksum($algorithm)
   {
-    switch($this->checksumAlgorithm)
+    switch ($algorithm)
     {
       case 'sha1':
         $this->checksum = sha1($this->contents);
         break;
+
       case 'md5':
-      default:
         $this->checksum = md5($this->contents);
-        $this->checksumAlgorithm = 'md5';
+        break;
+
+      default:
+        throw new Exception('Invalid checksum algorithm');
     }
+
+    $this->checksumAlgorithm = $algorithm;
+
+    return $this->checksum;
   }
 }

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to