Copie de Tumblr sur Shaarli
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.1KB

  1. <?php
  2. namespace League\HTMLToMarkdown;
  3. class Configuration
  4. {
  5. protected $config;
  6. /**
  7. * @param array $config
  8. */
  9. public function __construct(array $config = array())
  10. {
  11. $this->config = $config;
  12. }
  13. /**
  14. * @param array $config
  15. */
  16. public function merge(array $config = array())
  17. {
  18. $this->config = array_replace_recursive($this->config, $config);
  19. }
  20. /**
  21. * @param array $config
  22. */
  23. public function replace(array $config = array())
  24. {
  25. $this->config = $config;
  26. }
  27. /**
  28. * @param string $key
  29. * @param mixed $value
  30. */
  31. public function setOption($key, $value)
  32. {
  33. $this->config[$key] = $value;
  34. }
  35. /**
  36. * @param string|null $key
  37. * @param mixed|null $default
  38. *
  39. * @return mixed|null
  40. */
  41. public function getOption($key = null, $default = null)
  42. {
  43. if ($key === null) {
  44. return $this->config;
  45. }
  46. if (!isset($this->config[$key])) {
  47. return $default;
  48. }
  49. return $this->config[$key];
  50. }
  51. }