@@ -2,7 +2,6 @@ |
||
2 | 2 | namespace Ciandt\Behat\PlaceholdersExtension\Config; |
3 | 3 | |
4 | 4 | use Symfony\Component\Yaml\Yaml; |
5 | -use Ciandt\Behat\PlaceholdersExtension\Utils\PlaceholderUtils; |
|
6 | 5 | use Ciandt\Behat\PlaceholdersExtension\PlaceholderContainer\PlaceholderContainer; |
7 | 6 | use Ciandt\Behat\PlaceholdersExtension\Exception\MissingSectionException; |
8 | 7 | use Ciandt\Behat\PlaceholdersExtension\Exception\UndefinedPlaceholderException; |
@@ -62,7 +62,7 @@ |
||
62 | 62 | |
63 | 63 | public function getFilePath($key) |
64 | 64 | { |
65 | - if (key_exists($key, $this->configs)) { |
|
65 | + if (key_exists($key, $this->configs)) { |
|
66 | 66 | return $this->configs[$key]['path']; |
67 | 67 | } |
68 | 68 | return null; |
@@ -107,11 +107,11 @@ |
||
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | - private function getSectionPlaceholders(PlaceholderContainer $container){ |
|
110 | + private function getSectionPlaceholders(PlaceholderContainer $container) { |
|
111 | 111 | $configKey = $container->getConfigKey(); |
112 | 112 | $config = $this->getConfig($configKey); |
113 | 113 | $sectionKey = $container->getSectionKey(); |
114 | - if (!key_exists($sectionKey, $config)){ |
|
114 | + if (!key_exists($sectionKey, $config)) { |
|
115 | 115 | throw new MissingSectionException( |
116 | 116 | $configKey, |
117 | 117 | $this->getFilePath($configKey), |
@@ -2,11 +2,8 @@ discard block |
||
2 | 2 | namespace Ciandt\Behat\PlaceholdersExtension\ServiceContainer; |
3 | 3 | |
4 | 4 | use Ciandt\Behat\PlaceholdersExtension\Config\PlaceholdersRepository; |
5 | -use Ciandt\Behat\PlaceholdersExtension\Tester\PerVariantScenarioTester; |
|
6 | -use Ciandt\Behat\PlaceholdersExtension\Tester\PlaceholderReplacingStepTester; |
|
7 | 5 | use Ciandt\Behat\PlaceholdersExtension\Utils\PlaceholderUtils; |
8 | 6 | use Behat\Testwork\Cli\ServiceContainer\CliExtension; |
9 | -use Behat\Testwork\EventDispatcher\ServiceContainer\EventDispatcherExtension; |
|
10 | 7 | use Behat\Testwork\ServiceContainer\Extension; |
11 | 8 | use Behat\Testwork\ServiceContainer\ExtensionManager; |
12 | 9 | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
@@ -14,7 +11,6 @@ discard block |
||
14 | 11 | use Symfony\Component\DependencyInjection\Definition; |
15 | 12 | use Symfony\Component\DependencyInjection\Reference; |
16 | 13 | use Behat\Behat\Tester\ServiceContainer\TesterExtension; |
17 | -use Behat\Testwork\Environment\ServiceContainer\EnvironmentExtension; |
|
18 | 14 | use Behat\Behat\Transformation\ServiceContainer\TransformationExtension; |
19 | 15 | |
20 | 16 | final class PlaceholdersExtension implements Extension |
@@ -101,7 +101,7 @@ |
||
101 | 101 | $container->setDefinition(self::PLACEHOLDERS_CONTROLLER_ID, $definition); |
102 | 102 | } |
103 | 103 | |
104 | - protected function initializePlaceholderUtils($variantTags,$configTags){ |
|
104 | + protected function initializePlaceholderUtils($variantTags, $configTags) { |
|
105 | 105 | PlaceholderUtils::setVariantTags($variantTags); |
106 | 106 | PlaceholderUtils::setConfigKeys(array_keys($configTags)); |
107 | 107 | } |
@@ -25,6 +25,9 @@ |
||
25 | 25 | return self::USER_DEFINED_PLACEHOLDER_REGEX; |
26 | 26 | } |
27 | 27 | |
28 | + /** |
|
29 | + * @param string $string |
|
30 | + */ |
|
28 | 31 | private static function replaceStringPlaceholders($string, PlaceholdersRepository $repository, PlaceholderContainerStepNode $container) { |
29 | 32 | preg_match_all(self::USER_DEFINED_PLACEHOLDER_REGEX, $string, $matches, PREG_SET_ORDER); |
30 | 33 | foreach ($matches as $match) { |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace Ciandt\Behat\PlaceholdersExtension\Transformer; |
4 | 4 | |
5 | 5 | use Behat\Behat\Transformation\Transformer\ArgumentTransformer; |
6 | -use Ciandt\Behat\PlaceholdersExtension\PlaceholderContainer\PlaceholderContainerStepNode; |
|
7 | 6 | use Ciandt\Behat\PlaceholdersExtension\Transformation\RuntimePlaceholdersTransformation; |
8 | 7 | use Behat\Behat\Definition\Call\DefinitionCall; |
9 | 8 | use Ciandt\Behat\PlaceholdersExtension\Config\PlaceholdersRepository; |
@@ -10,7 +10,6 @@ |
||
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Transforms a single argument value. |
13 | - |
|
14 | 13 | */ |
15 | 14 | class PlaceholdersTransformer implements ArgumentTransformer |
16 | 15 | { |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | public function transformArgument(DefinitionCall $definitionCall, $argumentIndex, $argumentValue) { |
30 | 30 | $transformedArgument = $argumentValue; |
31 | - if (RuntimePlaceholdersTransformation::supportsDefinitionAndArgument($definitionCall, $argumentValue)){ |
|
31 | + if (RuntimePlaceholdersTransformation::supportsDefinitionAndArgument($definitionCall, $argumentValue)) { |
|
32 | 32 | $transformedArgument = RuntimePlaceholdersTransformation::transformArgument( |
33 | 33 | $transformedArgument, |
34 | 34 | $this->placeholdersRepository, |
@@ -9,7 +9,7 @@ |
||
9 | 9 | * |
10 | 10 | * @author bwowk |
11 | 11 | */ |
12 | -class MissingSectionException extends RuntimeException{ |
|
12 | +class MissingSectionException extends RuntimeException { |
|
13 | 13 | |
14 | 14 | |
15 | 15 | public function __construct($configKey, $configPath, $section) { |
@@ -8,6 +8,6 @@ |
||
8 | 8 | * |
9 | 9 | * @author bwowk |
10 | 10 | */ |
11 | -class UndefinedPlaceholderException extends RuntimeException{ |
|
11 | +class UndefinedPlaceholderException extends RuntimeException { |
|
12 | 12 | //put your code here |
13 | 13 | } |
@@ -9,7 +9,7 @@ |
||
9 | 9 | * |
10 | 10 | * @author bwowk |
11 | 11 | */ |
12 | -class RedundantConfigTagException extends RuntimeException{ |
|
12 | +class RedundantConfigTagException extends RuntimeException { |
|
13 | 13 | public function __construct($tags) { |
14 | 14 | $message = "Multiple config tags found. Should have only one: " . implode(', ', $tags); |
15 | 15 | parent::__construct($message); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * |
11 | 11 | * @author bwowk |
12 | 12 | */ |
13 | -class PlaceholderContainerStepNode extends StepNode implements PlaceholderContainer{ |
|
13 | +class PlaceholderContainerStepNode extends StepNode implements PlaceholderContainer { |
|
14 | 14 | |
15 | 15 | private $stepNode; |
16 | 16 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | private $sectionKey; |
22 | 22 | |
23 | - function __construct($stepNode,$configKey, $sectionKey, $variant) { |
|
23 | + function __construct($stepNode, $configKey, $sectionKey, $variant) { |
|
24 | 24 | $this->stepNode = $stepNode; |
25 | 25 | $this->configKey = $configKey; |
26 | 26 | $this->sectionKey = $sectionKey; |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | self::$configKeys = $configKeys; |
26 | 26 | } |
27 | 27 | |
28 | - public static function getSectionKey($tag){ |
|
28 | + public static function getSectionKey($tag) { |
|
29 | 29 | $tagParts = explode(':', $tag); |
30 | - if (count($tagParts) == 2){ |
|
30 | + if (count($tagParts) == 2) { |
|
31 | 31 | return $tagParts[1]; |
32 | 32 | } else { |
33 | 33 | return 'default'; |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | - public static function getConfigTag($tags){ |
|
39 | - $configTags = self::filterConfigTags($tags,false); |
|
38 | + public static function getConfigTag($tags) { |
|
39 | + $configTags = self::filterConfigTags($tags, false); |
|
40 | 40 | if (empty($configTags)) { |
41 | 41 | return false; |
42 | 42 | } |
@@ -47,25 +47,25 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | - public static function getConfigKey($tag){ |
|
50 | + public static function getConfigKey($tag) { |
|
51 | 51 | return explode(':', $tag)[0]; |
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public static function filterVariantTags($tags, $exclude) |
56 | 56 | { |
57 | - return array_filter($tags, function ($tag) use ($exclude) { |
|
57 | + return array_filter($tags, function($tag) use ($exclude) { |
|
58 | 58 | return (in_array($tag, self::$variantTags) xor $exclude); |
59 | 59 | }); |
60 | 60 | } |
61 | 61 | |
62 | - public static function getVariant($tags){ |
|
62 | + public static function getVariant($tags) { |
|
63 | 63 | $variantTags = self::filterVariantTags($tags, false); |
64 | 64 | if (count($variantTags) > 1) { |
65 | 65 | throw new \RuntimeException("Scenario should only have one variant tag." |
66 | 66 | . " Multiple found: " . implode(', ', $variantTags)); |
67 | 67 | } |
68 | - if (empty($variantTags)){ |
|
68 | + if (empty($variantTags)) { |
|
69 | 69 | return 'default'; |
70 | 70 | } |
71 | 71 | return end($variantTags); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | public static function filterConfigTags($tags, $exclude) |
76 | 76 | { |
77 | - return array_filter($tags, function ($tag) use ($exclude){ |
|
77 | + return array_filter($tags, function($tag) use ($exclude){ |
|
78 | 78 | return (in_array(self::getConfigKey($tag), self::$configKeys) xor $exclude); |
79 | 79 | }); |
80 | 80 | } |