Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Output / Node / Printer / Pretty / PrettyExamplePrinter.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\Output\Node\Printer\Pretty;
12
13 use Behat\Behat\Output\Node\Printer\ExamplePrinter;
14 use Behat\Gherkin\Node\ExampleNode;
15 use Behat\Gherkin\Node\FeatureNode;
16 use Behat\Testwork\Output\Formatter;
17 use Behat\Testwork\Output\Printer\OutputPrinter;
18 use Behat\Testwork\Tester\Result\TestResult;
19
20 /**
21  * Prints example header (usually simply an example row) and footer.
22  *
23  * @author Konstantin Kudryashov <ever.zet@gmail.com>
24  */
25 final class PrettyExamplePrinter implements ExamplePrinter
26 {
27     /**
28      * @var PrettyPathPrinter
29      */
30     private $pathPrinter;
31     /**
32      * @var string
33      */
34     private $indentText;
35
36     /**
37      * Initializes printer.
38      *
39      * @param PrettyPathPrinter $pathPrinter
40      * @param integer           $indentation
41      */
42     public function __construct(PrettyPathPrinter $pathPrinter, $indentation = 6)
43     {
44         $this->pathPrinter = $pathPrinter;
45         $this->indentText = str_repeat(' ', intval($indentation));
46     }
47
48     /**
49      * {@inheritdoc}
50      */
51     public function printHeader(Formatter $formatter, FeatureNode $feature, ExampleNode $example)
52     {
53         $this->printTitle($formatter->getOutputPrinter(), $example);
54         $this->pathPrinter->printScenarioPath($formatter, $feature, $example, mb_strlen($this->indentText, 'utf8'));
55     }
56
57     /**
58      * {@inheritdoc}
59      */
60     public function printFooter(Formatter $formatter, TestResult $result)
61     {
62     }
63
64     /**
65      * Prints example title.
66      *
67      * @param OutputPrinter $printer
68      * @param ExampleNode   $example
69      */
70     private function printTitle(OutputPrinter $printer, ExampleNode $example)
71     {
72         $printer->write(sprintf('%s%s', $this->indentText, $example->getTitle()));
73     }
74 }