Behat\Gherkin\Keywords\KeywordsDumper::dump PHP Method

dump() public method

Dumps keyworded feature into string.
public dump ( string $language, boolean $short = true, boolean $excludeAsterisk = false ) : string | array
$language string Keywords language
$short boolean Dump short version
$excludeAsterisk boolean
return string | array String for short version and array of features for extended
    public function dump($language, $short = true, $excludeAsterisk = false)
    {
        $this->keywords->setLanguage($language);
        $languageComment = '';
        if ('en' !== $language) {
            $languageComment = "# language: {$language}\n";
        }
        $keywords = explode('|', $this->keywords->getFeatureKeywords());
        if ($short) {
            $keywords = call_user_func($this->keywordsDumper, $keywords, $short);
            return trim($languageComment . $this->dumpFeature($keywords, $short, $excludeAsterisk));
        }
        $features = array();
        foreach ($keywords as $keyword) {
            $keyword = call_user_func($this->keywordsDumper, array($keyword), $short);
            $features[] = trim($languageComment . $this->dumpFeature($keyword, $short, $excludeAsterisk));
        }
        return $features;
    }

Usage Example

Example #1
0
 /**
  * Prints example story syntax into console.
  *
  * @param   Symfony\Component\Console\Output\OutputInterface    $output
  * @param   string                                              $language
  */
 public function printSyntax(OutputInterface $output, $language = 'en')
 {
     $output->getFormatter()->setStyle('comment', new OutputFormatterStyle('yellow'));
     $output->getFormatter()->setStyle('keyword', new OutputFormatterStyle('green', null, array('bold')));
     $story = $this->dumper->dump($language);
     $story = preg_replace('/^\\#.*/', '<comment>$0</comment>', $story);
     $output->writeln($story);
 }
All Usage Examples Of Behat\Gherkin\Keywords\KeywordsDumper::dump