Permalink
Browse files

Fixed code formatting.

Added comments for setters.
  • Loading branch information...
1 parent 6565f32 commit 86649b61eb9880c135bd125b6e66a3b96ff70524 @djlambert djlambert committed with jmikola Jul 17, 2012
Showing with 16 additions and 5 deletions.
  1. +16 −5 lib/Doctrine/ODM/MongoDB/Id/AlnumGenerator.php
@@ -48,17 +48,27 @@ class AlnumGenerator extends IncrementGenerator
protected $awkwardSafeChars = '0123456789BCDFGHJKLMNPQRSTVWXZbcdfghjklmnpqrstvwxz';
+ /**
+ * Set padding on generated id
+ *
+ * @param int $pad
+ */
public function setPad($pad)
{
$this->pad = intval($pad);
}
+ /**
+ * Enable awkwardSafeMode character set
+ *
+ * @param bool $awkwardSafeMode
+ */
public function setAwkwardSafeMode($awkwardSafeMode = false)
{
$this->awkwardSafeMode = $awkwardSafeMode;
}
- /*
+ /**
* Set the character set used for ID generation
*
* @param string $chars ID character set
@@ -75,15 +85,16 @@ public function generate(DocumentManager $dm, $document)
$index = $this->awkwardSafeMode ? $this->awkwardSafeChars : $this->chars;
$base = strlen($index);
- $out = "";
+ $out = "";
do {
$out = $index[bcmod($id, $base)] . $out;
$id = bcdiv($id, $base);
} while (bccomp($id, 0) == 1);
- if(is_numeric($this->pad)) {
- $out = str_pad( $out, $this->pad, "0", STR_PAD_LEFT);
+ if (is_numeric($this->pad)) {
+ $out = str_pad($out, $this->pad, "0", STR_PAD_LEFT);
}
- return $out;
+
+ return $out;
}
}

0 comments on commit 86649b6

Please sign in to comment.