Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Context / Snippet / ContextSnippet.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\Snippet;
12
13 use Behat\Behat\Snippet\Snippet;
14 use Behat\Gherkin\Node\StepNode;
15
16 /**
17  * Represents a definition snippet for a context class.
18  *
19  * @author Konstantin Kudryashov <ever.zet@gmail.com>
20  */
21 final class ContextSnippet implements Snippet
22 {
23     /**
24      * @var StepNode
25      */
26     private $step;
27     /**
28      * @var string
29      */
30     private $template;
31     /**
32      * @var string
33      */
34     private $contextClass;
35     /**
36      * @var string[]
37      */
38     private $usedClasses;
39
40     /**
41      * Initializes definition snippet.
42      *
43      * @param StepNode $step
44      * @param string   $template
45      * @param string   $contextClass
46      * @param string[] $usedClasses
47      */
48     public function __construct(StepNode $step, $template, $contextClass, array $usedClasses = array())
49     {
50         $this->step = $step;
51         $this->template = $template;
52         $this->contextClass = $contextClass;
53         $this->usedClasses = $usedClasses;
54     }
55
56     /**
57      * {@inheritdoc}
58      */
59     public function getType()
60     {
61         return 'context';
62     }
63
64     /**
65      * {@inheritdoc}
66      */
67     public function getHash()
68     {
69         return md5($this->template);
70     }
71
72     /**
73      * {@inheritdoc}
74      */
75     public function getSnippet()
76     {
77         return sprintf($this->template, $this->step->getKeywordType());
78     }
79
80     /**
81      * {@inheritdoc}
82      */
83     public function getStep()
84     {
85         return $this->step;
86     }
87
88     /**
89      * {@inheritdoc}
90      */
91     public function getTarget()
92     {
93         return $this->contextClass;
94     }
95
96     /**
97      * Returns the classes used in the snippet which should be imported.
98      *
99      * @return string[]
100      */
101     public function getUsedClasses()
102     {
103         return $this->usedClasses;
104     }
105 }