You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
832 B

5 years ago
  1. <?php
  2. namespace App\Service\v3\Implementations;
  3. use App\Service\v3\Interfaces\HelperServiceInterface;
  4. class HelperService implements HelperServiceInterface
  5. {
  6. public function makeNumCode($length)
  7. {
  8. // 获取验证码
  9. $codeArr = array_map(function ($item) {
  10. return mt_rand(0,9);
  11. }, array_pad([], $length, 0));
  12. // 返回验证码
  13. return implode('', $codeArr);
  14. }
  15. /**
  16. * 请求参数判空
  17. * @param mixed $var 参数
  18. * @return bool
  19. */
  20. public function nonempty($var)
  21. {
  22. return ! (
  23. isset($var)
  24. && $var
  25. && !empty($var)
  26. && !is_null($var)
  27. && $var != 'undefined'
  28. && $var != 'unknown'
  29. && $var != 'null'
  30. && $var != 'false'
  31. );
  32. }
  33. }