HistoryTrait.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace AlibabaCloud\Client\Traits;
  3. /**
  4. * Trait HistoryTrait
  5. *
  6. * @package AlibabaCloud\Client\Traits
  7. */
  8. trait HistoryTrait
  9. {
  10. /**
  11. * @var array
  12. */
  13. private static $history = [];
  14. /**
  15. * @var bool
  16. */
  17. private static $isRememberHistory = false;
  18. /**
  19. * @return array
  20. */
  21. public static function getHistory()
  22. {
  23. return self::$history;
  24. }
  25. public static function forgetHistory()
  26. {
  27. self::$history = [];
  28. }
  29. public static function notRememberHistory()
  30. {
  31. self::$isRememberHistory = false;
  32. }
  33. public static function rememberHistory()
  34. {
  35. self::$isRememberHistory = true;
  36. }
  37. /**
  38. * @return bool
  39. */
  40. public static function isRememberHistory()
  41. {
  42. return self::$isRememberHistory;
  43. }
  44. /**
  45. * @return array
  46. */
  47. public static function &referenceHistory()
  48. {
  49. return self::$history;
  50. }
  51. /**
  52. * @return int
  53. */
  54. public static function countHistory()
  55. {
  56. return count(self::$history);
  57. }
  58. }