class FakeMetadataFactory

Hierarchy

Expanded class hierarchy of FakeMetadataFactory

2 files declare their use of FakeMetadataFactory
ValidationVisitorTest.php in drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidationVisitorTest.php
ValidatorTest.php in drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorTest.php

File

drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Fixtures/FakeMetadataFactory.php, line 18

Namespace

Symfony\Component\Validator\Tests\Fixtures
View source
class FakeMetadataFactory implements MetadataFactoryInterface {
  protected $metadatas = array();
  public function getMetadataFor($class) {
    if (is_object($class)) {
      $class = get_class($class);
    }
    if (!is_string($class)) {
      throw new NoSuchMetadataException(sprintf('No metadata for type %s', gettype($class)));
    }
    if (!isset($this->metadatas[$class])) {
      throw new NoSuchMetadataException(sprintf('No metadata for "%s"', $class));
    }
    return $this->metadatas[$class];
  }
  public function hasMetadataFor($class) {
    if (is_object($class)) {
      $class = get_class($class);
    }
    if (!is_string($class)) {
      return false;
    }
    return isset($this->metadatas[$class]);
  }
  public function addMetadata(ClassMetadata $metadata) {
    $this->metadatas[$metadata
      ->getClassName()] = $metadata;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FakeMetadataFactory::$metadatas protected property
FakeMetadataFactory::addMetadata public function
FakeMetadataFactory::getMetadataFor public function Returns the metadata for the given value. Overrides MetadataFactoryInterface::getMetadataFor
FakeMetadataFactory::hasMetadataFor public function Returns whether metadata exists for the given value. Overrides MetadataFactoryInterface::hasMetadataFor