SplArrayConfig.php 906 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace EasySwoole\Config;
  3. use EasySwoole\Spl\SplArray;
  4. class SplArrayConfig extends AbstractConfig
  5. {
  6. private $splArray;
  7. function __construct()
  8. {
  9. $this->splArray = new SplArray();
  10. }
  11. function getConf($key = null)
  12. {
  13. if($key === null){
  14. return $this->splArray->getArrayCopy();
  15. }
  16. return $this->splArray->get($key);
  17. }
  18. function setConf($key, $val): bool
  19. {
  20. $this->splArray->set($key,$val);
  21. return true;
  22. }
  23. function load(array $array): bool
  24. {
  25. $this->splArray->loadArray($array);
  26. return true;
  27. }
  28. function merge(array $array): bool
  29. {
  30. $this->splArray->merge($array);
  31. return true;
  32. }
  33. function clear(): bool
  34. {
  35. $this->load([]);
  36. return true;
  37. }
  38. function storage():SplArray
  39. {
  40. return $this->splArray;
  41. }
  42. }