Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Snippet / Printer / ConsoleSnippetPrinter.php
1 <?php
2
3 /*
4  * This file is part of the Behat.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Behat\Snippet\Printer;
12
13 use Behat\Behat\Snippet\AggregateSnippet;
14 use Behat\Gherkin\Node\StepNode;
15 use Symfony\Component\Console\Formatter\OutputFormatterStyle;
16 use Symfony\Component\Console\Output\OutputInterface;
17 use Symfony\Component\Translation\TranslatorInterface;
18
19 /**
20  * Behat console-based snippet printer.
21  *
22  * Extends default printer with default styles.
23  *
24  * @author Konstantin Kudryashov <ever.zet@gmail.com>
25  */
26 class ConsoleSnippetPrinter implements SnippetPrinter
27 {
28     /**
29      * @var OutputInterface
30      */
31     private $output;
32     /**
33      * @var TranslatorInterface
34      */
35     private $translator;
36
37     /**
38      * Initializes printer.
39      *
40      * @param OutputInterface     $output
41      * @param TranslatorInterface $translator
42      */
43     public function __construct(OutputInterface $output, TranslatorInterface $translator)
44     {
45         $this->output = $output;
46         $this->translator = $translator;
47
48         $output->getFormatter()->setStyle('snippet_keyword', new OutputFormatterStyle(null, null, array('bold')));
49         $output->getFormatter()->setStyle('snippet_undefined', new OutputFormatterStyle('yellow'));
50     }
51
52     /**
53      * Prints snippets of specific target.
54      *
55      * @param string             $targetName
56      * @param AggregateSnippet[] $snippets
57      */
58     public function printSnippets($targetName, array $snippets)
59     {
60         $message = $this->translator->trans('snippet_proposal_title', array('%1%' => $targetName), 'output');
61
62         $this->output->writeln('--- ' . $message . PHP_EOL);
63
64         foreach ($snippets as $snippet) {
65             $this->output->writeln(sprintf('<snippet_undefined>%s</snippet_undefined>', $snippet->getSnippet()) . PHP_EOL);
66         }
67     }
68
69     /**
70      * Prints undefined steps of specific suite.
71      *
72      * @param string     $suiteName
73      * @param StepNode[] $steps
74      */
75     public function printUndefinedSteps($suiteName, array $steps)
76     {
77         $message = $this->translator->trans('snippet_missing_title', array('%1%' => $suiteName), 'output');
78
79         $this->output->writeln('--- ' . $message . PHP_EOL);
80
81         foreach ($steps as $step) {
82             $this->output->writeln(sprintf('    <snippet_undefined>%s %s</snippet_undefined>', $step->getKeyword(), $step->getText()));
83         }
84
85         $this->output->writeln('');
86     }
87 }