Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Context / ContextClass / SimpleClassGenerator.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\Context\ContextClass;
12
13 use Behat\Testwork\Suite\Suite;
14
15 /**
16  * Generates basic PHP 5.3+ class with an optional namespace.
17  *
18  * @author Konstantin Kudryashov <ever.zet@gmail.com>
19  */
20 final class SimpleClassGenerator implements ClassGenerator
21 {
22     /**
23      * @var string
24      */
25     protected static $template = <<<'PHP'
26 <?php
27
28 {namespace}use Behat\Behat\Context\Context;
29 use Behat\Gherkin\Node\PyStringNode;
30 use Behat\Gherkin\Node\TableNode;
31
32 /**
33  * Defines application features from the specific context.
34  */
35 class {className} implements Context
36 {
37     /**
38      * Initializes context.
39      *
40      * Every scenario gets its own context instance.
41      * You can also pass arbitrary arguments to the
42      * context constructor through behat.yml.
43      */
44     public function __construct()
45     {
46     }
47 }
48
49 PHP;
50
51     /**
52      * {@inheritdoc}
53      */
54     public function supportsSuiteAndClass(Suite $suite, $contextClass)
55     {
56         return true;
57     }
58
59     /**
60      * {@inheritdoc}
61      */
62     public function generateClass(Suite $suite, $contextClass)
63     {
64         $fqn = $contextClass;
65
66         $namespace = '';
67         if (false !== $pos = strrpos($fqn, '\\')) {
68             $namespace = 'namespace ' . substr($fqn, 0, $pos) . ";\n\n";
69             $contextClass = substr($fqn, $pos + 1);
70         }
71
72         return strtr(
73             static::$template,
74             array(
75                 '{namespace}' => $namespace,
76                 '{className}' => $contextClass,
77             )
78         );
79     }
80 }