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\Definition\Context\Annotation;
13 use Behat\Behat\Context\Annotation\AnnotationReader;
17 * Reads definition annotations from the context class.
19 * @author Konstantin Kudryashov <ever.zet@gmail.com>
21 final class DefinitionAnnotationReader implements AnnotationReader
26 private static $regex = '/^\@(given|when|then)\s+(.+)$/i';
30 private static $classes = array(
31 'given' => 'Behat\Behat\Definition\Call\Given',
32 'when' => 'Behat\Behat\Definition\Call\When',
33 'then' => 'Behat\Behat\Definition\Call\Then',
39 public function readCallee($contextClass, ReflectionMethod $method, $docLine, $description)
41 if (!preg_match(self::$regex, $docLine, $match)) {
45 $type = strtolower($match[1]);
46 $class = self::$classes[$type];
48 $callable = array($contextClass, $method->getName());
50 return new $class($pattern, $callable, $description);