private function createResourceFromSpecFile($path)
{
$classname = $this->findSpecClassname($path);
if (null === $classname) {
throw new \RuntimeException(sprintf('Spec file "%s" does not contains any class definition.', $path));
}
// Remove spec namespace from the begining of the classname.
$specNamespace = trim($this->getSpecNamespace(), '\\') . '\\';
if (0 !== strpos($classname, $specNamespace)) {
throw new \RuntimeException(sprintf('Spec class `%s` must be in the base spec namespace `%s`.', $classname, $this->getSpecNamespace()));
}
$classname = substr($classname, strlen($specNamespace));
// cut "Spec" from the end
$classname = preg_replace('/Spec$/', '', $classname);
// Create the resource
return new PSR0Resource(explode('\\', $classname), $this);
}