Açıklama Yok

SafeStorage.php 744B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace League\Flysystem;
  3. final class SafeStorage
  4. {
  5. /**
  6. * @var string
  7. */
  8. private $hash;
  9. /**
  10. * @var array
  11. */
  12. protected static $safeStorage = [];
  13. public function __construct()
  14. {
  15. $this->hash = spl_object_hash($this);
  16. static::$safeStorage[$this->hash] = [];
  17. }
  18. public function storeSafely($key, $value)
  19. {
  20. static::$safeStorage[$this->hash][$key] = $value;
  21. }
  22. public function retrieveSafely($key)
  23. {
  24. if (array_key_exists($key, static::$safeStorage[$this->hash])) {
  25. return static::$safeStorage[$this->hash][$key];
  26. }
  27. }
  28. public function __destruct()
  29. {
  30. unset(static::$safeStorage[$this->hash]);
  31. }
  32. }