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