暂无描述

ConfigAwareTrait.php 851B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace League\Flysystem;
  3. /**
  4. * @internal
  5. */
  6. trait ConfigAwareTrait
  7. {
  8. /**
  9. * @var Config
  10. */
  11. protected $config;
  12. /**
  13. * Set the config.
  14. *
  15. * @param Config|array|null $config
  16. */
  17. protected function setConfig($config)
  18. {
  19. $this->config = $config ? Util::ensureConfig($config) : new Config;
  20. }
  21. /**
  22. * Get the Config.
  23. *
  24. * @return Config config object
  25. */
  26. public function getConfig()
  27. {
  28. return $this->config;
  29. }
  30. /**
  31. * Convert a config array to a Config object with the correct fallback.
  32. *
  33. * @param array $config
  34. *
  35. * @return Config
  36. */
  37. protected function prepareConfig(array $config)
  38. {
  39. $config = new Config($config);
  40. $config->setFallback($this->getConfig());
  41. return $config;
  42. }
  43. }