Created
January 7, 2016 13:02
-
-
Save tperrelli/e8d8d5948deb8dd15b82 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Helpers; | |
class Cupom | |
{ | |
public static function generate($len = 5) | |
{ | |
$chars = strtoupper(md5(uniqid(mt_rand()))); | |
$str = ''; | |
for ($i = 0; $i < $len; $i++) | |
{ | |
$position = mt_rand(0, strlen($chars)); | |
$str .= substr($chars, $position, 1); | |
} | |
return $str; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment