2 /* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
3 and is published under the AGPL license. */
8 protected static $_allowed = "0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
9 public static function generate($length = 8, $allowed = null) {
10 if (!$allowed or !is_string($allowed)) {
11 $allowed = self::$_allowed;
14 return array_reduce(range(0, $length), function($res) use ($allowed) {
15 return $res . $allowed[mt_rand(0,strlen($allowed) - 1)];