public function FakeMetadataFactory::getMetadataFor in Plug 7
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
- lib/
Symfony/ validator/ Symfony/ Component/ 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];
}