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
22 * @internal This property is public in order to reduce the size of the
23 * class' serialized representation. Do not access it. Use
24 * {@link getName()} instead.
29 * @internal This property is public in order to reduce the size of the
30 * class' serialized representation. Do not access it. Use
31 * {@link getGroups()} instead.
33 public $groups = array();
38 * @internal This property is public in order to reduce the size of the
39 * class' serialized representation. Do not access it. Use
40 * {@link getMaxDepth()} instead.
45 * Constructs a metadata for the given attribute.
49 public function __construct($name)
57 public function getName()
65 public function addGroup($group)
67 if (!\in_array($group, $this->groups)) {
68 $this->groups[] = $group;
75 public function getGroups()
83 public function setMaxDepth($maxDepth)
85 $this->maxDepth = $maxDepth;
91 public function getMaxDepth()
93 return $this->maxDepth;
99 public function merge(AttributeMetadataInterface $attributeMetadata)
101 foreach ($attributeMetadata->getGroups() as $group) {
102 $this->addGroup($group);
105 // Overwrite only if not defined
106 if (null === $this->maxDepth) {
107 $this->maxDepth = $attributeMetadata->getMaxDepth();
112 * Returns the names of the properties that should be serialized.
116 public function __sleep()
118 return array('name', 'groups', 'maxDepth');