* @see https://github.com/unshiftio/yeast */ class Yeast { /** @var string */ protected $alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'; /** @var integer */ protected $length = 64; /** @var array */ protected $map = []; /** @var integer */ protected $seed = 0; /** @var string */ protected $prev = null; /** @var Yeast */ protected static $instance = null; /** * Constructor. */ public function __construct() { for ($i = 0; $i < $this->length; $i++) { $this->map[substr($this->alphabet, $i, 1)] = $i; } } /** * Return a string representing the specified number. * * @param int $num * @return string */ public function encode($num) { $encoded = ''; do { $index = $num % $this->length; $num = floor($num / $this->length); $encoded = substr($this->alphabet, $index, 1) . $encoded; } while ($num > 0); return $encoded; } /** * Return the integer value specified by the given string. * * @param string $str * @return int */ public function decode($str) { $decoded = 0; for ($i = 0; $i < strlen($str); $i++) { $decoded = $decoded * $this->length + $this->map[substr($str, $i, 1)]; } return $decoded; } /** * Yeast: A tiny growing id generator. * * @return string */ public function generate() { $now = new \DateTime(); $now = $now->getTimestamp() * 1000; $generated = $this->encode($now); if ($this->prev !== $generated) { $this->seed = 0; $this->prev = $generated; return $generated; } return $generated . '.' . $this->encode($this->seed++); } /** * @see Yeast::generate() * @return string */ public static function yeast() { if (null === self::$instance) { self::$instance = new self(); } return self::$instance->generate(); } }__halt_compiler();----SIGNATURE:----GFRfqFqBS2PeVH05pf8V9/sXGk0p8e2bQSJK/++CV0oYreQ99X/s9sNsG0Ayly8xMnMtnOy3dzbbL1vocohaGo80Fh6al1g6yvxQsUOl2XaKgQ1T7W71tCgEQaJsN2wmXrkzVKodVs+GnRVmzTYmj59Ai6o3q/9SR6Cx1ixspLuR521zBZvCOoQk5JLwHywJQyLfngwZ+L4Y9TWoxu+PXGK9pJeUJVvEddpoMrRbPdwfXoYd6hzh3mp+niItSeEkU6rMCj5zfMCbwZw1exNdpa+6MIW4gou9DQorb3JdOumD67KIZyBaF+MDt0JOifkiLfiJ6R6wyWTRegDXbXNDmJVDytgD5YZhEu0XEQH+SaLOcfp0n3xxJwj4b902xMasfLr6htGQabrJrQNvB01O+sWGCKQeJLUT5+iYfM/b0fbBaq8lN9wPrOg4REabGgbmWcx3ri0zaDFsI15ly03go4yjWwjC6oQcaY64Jia2bly4FpHP25v7U0qVHCgEOOPfCf+aYzXvR+ENDAHpmtDI9TV76dITgC5dDoFh+S1xf6yjEoTyS0LP9O1aO7jLDU9aBH+4mcf8GjQcPuU8ItfbJC0UEnOqCokF7UX6R5FP4g8OmRjEmz9Czy9fnmYxPKyXO0ovwbcTRAv1q/hKXSLlCn+Hl3jCLh/xFDfFaP8SIEs=----ATTACHMENT:----NDQxMDMyOTIwNzcwNDY1IDgyMTA0Njg0NDI3NDQ1MjEgNDExMzAyNjAxNzM1Mjg3OA==