HistoryTrait.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. }