public function FakeMetadataFactory::getMetadataFor in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/Tests/Fixtures/FakeMetadataFactory.php \Symfony\Component\Validator\Tests\Fixtures\FakeMetadataFactory::getMetadataFor()
Returns the metadata for the given value.
Parameters
mixed $value Some value:
Return value
MetadataInterface The metadata for the value
Throws
Exception\NoSuchMetadataException If no metadata exists for the given value
Overrides MetadataFactoryInterface::getMetadataFor
File
- vendor/
symfony/ validator/ Tests/ Fixtures/ FakeMetadataFactory.php, line 22
Class
Namespace
Symfony\Component\Validator\Tests\FixturesCode
public function getMetadataFor($class) {
$hash = null;
if (is_object($class)) {
$hash = spl_object_hash($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])) {
if (isset($this->metadatas[$hash])) {
return $this->metadatas[$hash];
}
throw new NoSuchMetadataException(sprintf('No metadata for "%s"', $class));
}
return $this->metadatas[$class];
}