NodeInterface.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Config\Definition;
  11. use Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException;
  12. use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
  13. use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
  14. /**
  15. * Common Interface among all nodes.
  16. *
  17. * In most cases, it is better to inherit from BaseNode instead of implementing
  18. * this interface yourself.
  19. *
  20. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  21. */
  22. interface NodeInterface
  23. {
  24. /**
  25. * Returns the name of the node.
  26. *
  27. * @return string The name of the node
  28. */
  29. public function getName();
  30. /**
  31. * Returns the path of the node.
  32. *
  33. * @return string The node path
  34. */
  35. public function getPath();
  36. /**
  37. * Returns true when the node is required.
  38. *
  39. * @return bool If the node is required
  40. */
  41. public function isRequired();
  42. /**
  43. * Returns true when the node has a default value.
  44. *
  45. * @return bool If the node has a default value
  46. */
  47. public function hasDefaultValue();
  48. /**
  49. * Returns the default value of the node.
  50. *
  51. * @return mixed The default value
  52. *
  53. * @throws \RuntimeException if the node has no default value
  54. */
  55. public function getDefaultValue();
  56. /**
  57. * Normalizes a value.
  58. *
  59. * @param mixed $value The value to normalize
  60. *
  61. * @return mixed The normalized value
  62. *
  63. * @throws InvalidTypeException if the value type is invalid
  64. */
  65. public function normalize($value);
  66. /**
  67. * Merges two values together.
  68. *
  69. * @param mixed $leftSide
  70. * @param mixed $rightSide
  71. *
  72. * @return mixed The merged value
  73. *
  74. * @throws ForbiddenOverwriteException if the configuration path cannot be overwritten
  75. * @throws InvalidTypeException if the value type is invalid
  76. */
  77. public function merge($leftSide, $rightSide);
  78. /**
  79. * Finalizes a value.
  80. *
  81. * @param mixed $value The value to finalize
  82. *
  83. * @return mixed The finalized value
  84. *
  85. * @throws InvalidTypeException if the value type is invalid
  86. * @throws InvalidConfigurationException if the value is invalid configuration
  87. */
  88. public function finalize($value);
  89. }