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 ClassMetadata implements ClassMetadataInterface
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 * @var AttributeMetadataInterface[]
31 * @internal This property is public in order to reduce the size of the
32 * class' serialized representation. Do not access it. Use
33 * {@link getAttributesMetadata()} instead.
35 public $attributesMetadata = array();
38 * @var \ReflectionClass
43 * Constructs a metadata for the given class.
45 * @param string $class
47 public function __construct($class)
55 public function getName()
63 public function addAttributeMetadata(AttributeMetadataInterface $attributeMetadata)
65 $this->attributesMetadata[$attributeMetadata->getName()] = $attributeMetadata;
71 public function getAttributesMetadata()
73 return $this->attributesMetadata;
79 public function merge(ClassMetadataInterface $classMetadata)
81 foreach ($classMetadata->getAttributesMetadata() as $attributeMetadata) {
82 if (isset($this->attributesMetadata[$attributeMetadata->getName()])) {
83 $this->attributesMetadata[$attributeMetadata->getName()]->merge($attributeMetadata);
85 $this->addAttributeMetadata($attributeMetadata);
93 public function getReflectionClass()
95 if (!$this->reflClass) {
96 $this->reflClass = new \ReflectionClass($this->getName());
99 return $this->reflClass;
103 * Returns the names of the properties that should be serialized.
107 public function __sleep()
111 'attributesMetadata',