protected function prepareFromYaml(array $categories = []) : array
    {
        $data = array();

        foreach ($this->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)) {
                    continue;
                }

                array_walk($fileData['questions'], function (&$item) use ($category) {
                    $item['category'] = $category;
                });

                $data = array_merge($data, $fileData['questions']);
            }
        }

        return $data;
    }
protected function prepareFromYaml(array $categories = []) : array
    {
        $data = array();

        foreach ($this->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)) {
                    continue;
                }

                array_walk($fileData['questions'], function (&$item) use ($category) {
                    $item['category'] = $category;
                });

                $data = array_merge($data, $fileData['questions']);
            }
        }

        return $data;
    }
protected function prepareFromYaml ( array $ categories = [ ] ) : array { $ data = array ( ) ; foreach ( $ this -> 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 ) ) { continue ; } array_walk ( $ fileData [ 'questions' ] , function ( & $ item ) use ( $ category ) { $ item [ 'category' ] = $ category ; } ) ; $ data = array_merge ( $ data , $ fileData [ 'questions' ] ) ; } } return $ data ; }
Prepares data from Yaml files and returns an array of questions

@param array $categories : List of categories which should be included, empty array = all

@return array
Prepares data from Yaml files and returns an array of questions