You are here

class ClassMetadata in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/validator/Mapping/ClassMetadata.php \Symfony\Component\Validator\Mapping\ClassMetadata
  2. 8.0 vendor/symfony/serializer/Mapping/ClassMetadata.php \Symfony\Component\Serializer\Mapping\ClassMetadata
Same name and namespace in other branches
  1. 8 vendor/symfony/serializer/Mapping/ClassMetadata.php \Symfony\Component\Serializer\Mapping\ClassMetadata

@author Kévin Dunglas <dunglas@gmail.com>

Hierarchy

Expanded class hierarchy of ClassMetadata

6 files declare their use of ClassMetadata
AnnotationLoaderTest.php in vendor/symfony/serializer/Tests/Mapping/Loader/AnnotationLoaderTest.php
ClassMetadataFactory.php in vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactory.php
ClassMetadataTest.php in vendor/symfony/serializer/Tests/Mapping/ClassMetadataTest.php
TestClassMetadataFactory.php in vendor/symfony/serializer/Tests/Mapping/TestClassMetadataFactory.php
XmlFileLoaderTest.php in vendor/symfony/serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php

... See full list

File

vendor/symfony/serializer/Mapping/ClassMetadata.php, line 19

Namespace

Symfony\Component\Serializer\Mapping
View source
class ClassMetadata implements ClassMetadataInterface {

  /**
   * @var string
   *
   * @internal This property is public in order to reduce the size of the
   *           class' serialized representation. Do not access it. Use
   *           {@link getName()} instead.
   */
  public $name;

  /**
   * @var AttributeMetadataInterface[]
   *
   * @internal This property is public in order to reduce the size of the
   *           class' serialized representation. Do not access it. Use
   *           {@link getAttributesMetadata()} instead.
   */
  public $attributesMetadata = array();

  /**
   * @var \ReflectionClass
   */
  private $reflClass;

  /**
   * Constructs a metadata for the given class.
   *
   * @param string $class
   */
  public function __construct($class) {
    $this->name = $class;
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return $this->name;
  }

  /**
   * {@inheritdoc}
   */
  public function addAttributeMetadata(AttributeMetadataInterface $attributeMetadata) {
    $this->attributesMetadata[$attributeMetadata
      ->getName()] = $attributeMetadata;
  }

  /**
   * {@inheritdoc}
   */
  public function getAttributesMetadata() {
    return $this->attributesMetadata;
  }

  /**
   * {@inheritdoc}
   */
  public function merge(ClassMetadataInterface $classMetadata) {
    foreach ($classMetadata
      ->getAttributesMetadata() as $attributeMetadata) {
      if (isset($this->attributesMetadata[$attributeMetadata
        ->getName()])) {
        $this->attributesMetadata[$attributeMetadata
          ->getName()]
          ->merge($attributeMetadata);
      }
      else {
        $this
          ->addAttributeMetadata($attributeMetadata);
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getReflectionClass() {
    if (!$this->reflClass) {
      $this->reflClass = new \ReflectionClass($this
        ->getName());
    }
    return $this->reflClass;
  }

  /**
   * Returns the names of the properties that should be serialized.
   *
   * @return string[]
   */
  public function __sleep() {
    return array(
      'name',
      'attributesMetadata',
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ClassMetadata::$attributesMetadata public property @internal This property is public in order to reduce the size of the class' serialized representation. Do not access it. Use {@link getAttributesMetadata()} instead.
ClassMetadata::$name public property @internal This property is public in order to reduce the size of the class' serialized representation. Do not access it. Use {@link getName()} instead.
ClassMetadata::$reflClass private property
ClassMetadata::addAttributeMetadata public function Adds an {@link AttributeMetadataInterface}. Overrides ClassMetadataInterface::addAttributeMetadata
ClassMetadata::getAttributesMetadata public function Gets the list of {@link AttributeMetadataInterface}. Overrides ClassMetadataInterface::getAttributesMetadata
ClassMetadata::getName public function Returns the name of the backing PHP class. Overrides ClassMetadataInterface::getName
ClassMetadata::getReflectionClass public function Returns a {@link \ReflectionClass} instance for this class. Overrides ClassMetadataInterface::getReflectionClass
ClassMetadata::merge public function Merges a {@link ClassMetadataInterface} in the current one. Overrides ClassMetadataInterface::merge
ClassMetadata::__construct public function Constructs a metadata for the given class.
ClassMetadata::__sleep public function Returns the names of the properties that should be serialized.