4764e17720b339787e3a9e4c9a4ffea6feb6f9c8
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Output / Printer / ConsoleOutputFactory.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\Printer;
12
13 use Behat\Behat\Output\Printer\Formatter\ConsoleFormatter;
14 use Behat\Testwork\Output\Printer\Factory\ConsoleOutputFactory as BaseFactory;
15 use Symfony\Component\Console\Formatter\OutputFormatterStyle;
16
17 /**
18  * Extends default printer with default styles.
19  *
20  * @author Konstantin Kudryashov <ever.zet@gmail.com>
21  */
22 final class ConsoleOutputFactory extends BaseFactory
23 {
24     /**
25      * {@inheritDoc}
26      */
27     protected function createOutputFormatter()
28     {
29         $formatter = new ConsoleFormatter($this->isOutputDecorated());
30
31         foreach ($this->getDefaultStyles() as $name => $style) {
32             $formatter->setStyle($name, $style);
33         }
34
35         return $formatter;
36     }
37
38     /**
39      * Returns default styles.
40      *
41      * @return OutputFormatterStyle[string]
42      */
43     private function getDefaultStyles()
44     {
45         return array(
46             'keyword'       => new OutputFormatterStyle(null, null, array('bold')),
47             'stdout'        => new OutputFormatterStyle(null, null, array()),
48             'exception'     => new OutputFormatterStyle('red'),
49             'undefined'     => new OutputFormatterStyle('yellow'),
50             'pending'       => new OutputFormatterStyle('yellow'),
51             'pending_param' => new OutputFormatterStyle('yellow', null, array('bold')),
52             'failed'        => new OutputFormatterStyle('red'),
53             'failed_param'  => new OutputFormatterStyle('red', null, array('bold')),
54             'passed'        => new OutputFormatterStyle('green'),
55             'passed_param'  => new OutputFormatterStyle('green', null, array('bold')),
56             'skipped'       => new OutputFormatterStyle('cyan'),
57             'skipped_param' => new OutputFormatterStyle('cyan', null, array('bold')),
58             'comment'       => new OutputFormatterStyle('black'),
59             'tag'           => new OutputFormatterStyle('cyan')
60         );
61     }
62 }