/**
* Return a Benchmark instance for the given file or NULL if the
* given file contains no classes, or the class in the given file is
* abstract.
*
* @param string $file
*
* @return Benchmark
*/
public function getMetadataForFile($file)
{
$hierarchy = $this->reflector->reflect($file);
if ($hierarchy->isEmpty()) {
return;
}
if ($hierarchy->getTop() && true === $hierarchy->getTop()->abstract) {
return;
}
$metadata = $this->driver->getMetadataForHierarchy($hierarchy);
$this->validateBenchmark($hierarchy, $metadata);
// validate the subject and load the parameter sets
foreach ($metadata->getSubjects() as $subject) {
$this->validateSubject($hierarchy, $subject);
$paramProviders = $subject->getParamProviders();
$parameterSets = $this->reflector->getParameterSets($metadata->getPath(), $paramProviders);
foreach ($parameterSets as $parameterSet) {
if (!is_array($parameterSet)) {
throw new \InvalidArgumentException(sprintf('Each parameter set must be an array, got "%s" for %s::%s', gettype($parameterSet), $metadata->getClass(), $subject->getName()));
}
}
$subject->setParameterSets($parameterSets);
}
return $metadata;
}