protected static function prepareFromYaml(array $categories = array(), $path)
{
$data = array();
self::$count = 0;
$paths = Yaml::parse(file_get_contents($path))['paths'];
foreach ($paths as $path) {
$files = Finder::create()->files()->in($path)->name('*.yml');
foreach ($files as $file) {
$fileData = Yaml::parse($file->getContents());
$category = $fileData['category'];
if (count($categories) == 0 || in_array($category, $categories)) {
array_walk($fileData['questions'], function (&$item, $key) use($category) {
$item['category'] = $category;
});
$data = array_merge($data, $fileData['questions']);
}
}
}
self::$count = count($data);
return $data;
}