Config.php 841 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. declare(strict_types=1);
  3. namespace League\Flysystem;
  4. use function array_merge;
  5. class Config
  6. {
  7. public const OPTION_VISIBILITY = 'visibility';
  8. public const OPTION_DIRECTORY_VISIBILITY = 'directory_visibility';
  9. /**
  10. * @var array
  11. */
  12. private $options;
  13. public function __construct(array $options = [])
  14. {
  15. $this->options = $options;
  16. }
  17. /**
  18. * @param mixed $default
  19. *
  20. * @return mixed
  21. */
  22. public function get(string $property, $default = null)
  23. {
  24. return $this->options[$property] ?? $default;
  25. }
  26. public function extend(array $options): Config
  27. {
  28. return new Config(array_merge($this->options, $options));
  29. }
  30. public function withDefaults(array $defaults): Config
  31. {
  32. return new Config($this->options + $defaults);
  33. }
  34. }