4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Behat\Context\Snippet;
13 use Behat\Behat\Snippet\Snippet;
14 use Behat\Gherkin\Node\StepNode;
17 * Represents a definition snippet for a context class.
19 * @author Konstantin Kudryashov <ever.zet@gmail.com>
21 final class ContextSnippet implements Snippet
34 private $contextClass;
41 * Initializes definition snippet.
43 * @param StepNode $step
44 * @param string $template
45 * @param string $contextClass
46 * @param string[] $usedClasses
48 public function __construct(StepNode $step, $template, $contextClass, array $usedClasses = array())
51 $this->template = $template;
52 $this->contextClass = $contextClass;
53 $this->usedClasses = $usedClasses;
59 public function getType()
67 public function getHash()
69 return md5($this->template);
75 public function getSnippet()
77 return sprintf($this->template, $this->step->getKeywordType());
83 public function getStep()
91 public function getTarget()
93 return $this->contextClass;
97 * Returns the classes used in the snippet which should be imported.
101 public function getUsedClasses()
103 return $this->usedClasses;