4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Serializer\Mapping;
17 * @author Kévin Dunglas <dunglas@gmail.com>
19 class AttributeMetadata implements AttributeMetadataInterface
24 * @internal This property is public in order to reduce the size of the
25 * class' serialized representation. Do not access it. Use
26 * {@link getName()} instead.
33 * @internal This property is public in order to reduce the size of the
34 * class' serialized representation. Do not access it. Use
35 * {@link getGroups()} instead.
37 public $groups = array();
42 * @internal This property is public in order to reduce the size of the
43 * class' serialized representation. Do not access it. Use
44 * {@link getMaxDepth()} instead.
49 * Constructs a metadata for the given attribute.
53 public function __construct($name)
61 public function getName()
69 public function addGroup($group)
71 if (!in_array($group, $this->groups)) {
72 $this->groups[] = $group;
79 public function getGroups()
87 public function setMaxDepth($maxDepth)
89 $this->maxDepth = $maxDepth;
95 public function getMaxDepth()
97 return $this->maxDepth;
103 public function merge(AttributeMetadataInterface $attributeMetadata)
105 foreach ($attributeMetadata->getGroups() as $group) {
106 $this->addGroup($group);
109 // Overwrite only if not defined
110 if (null === $this->maxDepth) {
111 $this->maxDepth = $attributeMetadata->getMaxDepth();
116 * Returns the names of the properties that should be serialized.
120 public function __sleep()
122 return array('name', 'groups', 'maxDepth');