]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/property-access/Symfony/Component/PropertyAccess/PropertyAccessorInterface.php
twig implementation
[github/wallabag/wallabag.git] / vendor / symfony / property-access / Symfony / Component / PropertyAccess / PropertyAccessorInterface.php
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
12 namespace Symfony\Component\PropertyAccess;
13
14 /**
15 * Writes and reads values to/from an object/array graph.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19 interface PropertyAccessorInterface
20 {
21 /**
22 * Sets the value at the end of the property path of the object
23 *
24 * Example:
25 *
26 * use Symfony\Component\PropertyAccess\PropertyAccess;
27 *
28 * $propertyAccessor = PropertyAccess::getPropertyAccessor();
29 *
30 * echo $propertyAccessor->setValue($object, 'child.name', 'Fabien');
31 * // equals echo $object->getChild()->setName('Fabien');
32 *
33 * This method first tries to find a public setter for each property in the
34 * path. The name of the setter must be the camel-cased property name
35 * prefixed with "set".
36 *
37 * If the setter does not exist, this method tries to find a public
38 * property. The value of the property is then changed.
39 *
40 * If neither is found, an exception is thrown.
41 *
42 * @param object|array $objectOrArray The object or array to modify
43 * @param string|PropertyPathInterface $propertyPath The property path to modify
44 * @param mixed $value The value to set at the end of the property path
45 *
46 * @throws Exception\NoSuchPropertyException If a property does not exist or is not public.
47 * @throws Exception\UnexpectedTypeException If a value within the path is neither object
48 * nor array
49 */
50 public function setValue(&$objectOrArray, $propertyPath, $value);
51
52 /**
53 * Returns the value at the end of the property path of the object
54 *
55 * Example:
56 *
57 * use Symfony\Component\PropertyAccess\PropertyAccess;
58 *
59 * $propertyAccessor = PropertyAccess::getPropertyAccessor();
60 *
61 * echo $propertyAccessor->getValue($object, 'child.name);
62 * // equals echo $object->getChild()->getName();
63 *
64 * This method first tries to find a public getter for each property in the
65 * path. The name of the getter must be the camel-cased property name
66 * prefixed with "get", "is", or "has".
67 *
68 * If the getter does not exist, this method tries to find a public
69 * property. The value of the property is then returned.
70 *
71 * If none of them are found, an exception is thrown.
72 *
73 * @param object|array $objectOrArray The object or array to traverse
74 * @param string|PropertyPathInterface $propertyPath The property path to read
75 *
76 * @return mixed The value at the end of the property path
77 *
78 * @throws Exception\NoSuchPropertyException If a property does not exist or is not public.
79 */
80 public function getValue($objectOrArray, $propertyPath);
81 }