public function create(SplFileInfo $file)
{
try {
if (!preg_match('/^
--TEST-- \\r?\\n(?<title> .*?)
\\s --RULESET-- \\r?\\n(?<ruleset> .*?)
(?:\\s --CONFIG-- \\r?\\n(?<config> .*?))?
(?:\\s --SETTINGS-- \\r?\\n(?<settings> .*?))?
(?:\\s --REQUIREMENTS-- \\r?\\n(?<requirements> .*?))?
(?:\\s --EXPECT-- \\r?\\n(?<expect> .*?\\r?\\n*))?
(?:\\s --INPUT-- \\r?\\n(?<input> .*))?
$/sx', $file->getContents(), $match)) {
throw new \InvalidArgumentException('File format is invalid.');
}
$match = array_merge(array('config' => null, 'settings' => null, 'requirements' => null, 'expect' => null, 'input' => null), $match);
return new IntegrationCase($file->getRelativePathname(), $match['title'], $this->determineSettings($match['settings']), $this->determineRequirements($match['requirements']), $this->determineConfig($match['config']), $this->determineRuleset($match['ruleset']), $this->determineExpectedCode($match['expect'], $file), $this->determineInputCode($match['input'], $file));
} catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException(sprintf('%s Test file: "%s".', $e->getMessage(), $file->getRelativePathname()), $e->getCode(), $e);
}
}