StringUtils.php 573 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /*
  3. * This file is part of the php-phantomjs.
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. namespace JonnyW\PhantomJs;
  9. /**
  10. * PHP PhantomJs.
  11. *
  12. * @author Jon Wenmoth <contact@jonnyw.me>
  13. */
  14. final class StringUtils
  15. {
  16. /**
  17. * Generate random string.
  18. *
  19. * @static
  20. *
  21. * @param int $length (default: 20)
  22. *
  23. * @return string
  24. */
  25. public static function random($length = 20)
  26. {
  27. return substr(md5(mt_rand()), 0, $length);
  28. }
  29. }