Time.php 607 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * Created by PhpStorm
  4. * User:林志杰
  5. * Email:[email protected]
  6. * Motto:纵有疾风起,人生不言弃!
  7. * Time:2020/2/8 17:39
  8. */
  9. declare(strict_types=1);
  10. namespace app\common\lib;
  11. class Time
  12. {
  13. /**
  14. * 用户登录token保存时长
  15. * @param int $type
  16. * @return int
  17. */
  18. public static function userLoginExpiresTime(int $type = 2): int
  19. {
  20. $type = !in_array($type, [1, 2]) ? 2 : $type;
  21. if ($type === 1) {
  22. $day = 7;
  23. } elseif ($type === 2) {
  24. $day = 30;
  25. }
  26. return $day * 24 * 3600;
  27. }
  28. }