@@ -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,6 @@ |
||
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Transforms a single argument value. |
| 13 | - |
|
| 14 | 13 | */ |
| 15 | 14 | class PlaceholdersTransformer implements ArgumentTransformer |
| 16 | 15 | { |
@@ -27,8 +27,8 @@ |
||
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function transformArgument(DefinitionCall $definitionCall, $argumentIndex, $argumentValue) { |
| 30 | - if (RuntimePlaceholdersTransformation::supportsArgument($argumentValue)){ |
|
| 31 | - return RuntimePlaceholdersTransformation::transformArgument($argumentValue,$this->repository); |
|
| 30 | + if (RuntimePlaceholdersTransformation::supportsArgument($argumentValue)) { |
|
| 31 | + return RuntimePlaceholdersTransformation::transformArgument($argumentValue, $this->repository); |
|
| 32 | 32 | } |
| 33 | 33 | return $argumentValue; |
| 34 | 34 | } |
@@ -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 | } |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | ); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function onBeforeScenarioTested($beforeScenario){ |
|
| 34 | + public function onBeforeScenarioTested($beforeScenario) { |
|
| 35 | 35 | $featureTags = $beforeScenario->getFeature()->getTags(); |
| 36 | 36 | $scenarioTags = $beforeScenario->getNode()->getTags(); |
| 37 | 37 | $this->scenarioTags = array_merge($featureTags, $scenarioTags); |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $filename = $this->findRelativePath($path); |
| 34 | 34 | $content = file_get_contents($path); |
| 35 | 35 | $feature = $this->parser->parse($content, $filename); |
| 36 | - return null === $feature? $feature : $this->branchFeatureVariants($feature); |
|
| 36 | + return null === $feature ? $feature : $this->branchFeatureVariants($feature); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -47,7 +47,6 @@ |
||
| 47 | 47 | /** |
| 48 | 48 | * reads the YAML placeholder definitions and returns an associative array |
| 49 | 49 | * |
| 50 | - * @param type $config_files |
|
| 51 | 50 | * @todo use %paths.base% value |
| 52 | 51 | * @return array |
| 53 | 52 | */ |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Symfony\Component\Yaml\Yaml; |
| 5 | 5 | use Ciandt\Behat\PlaceholdersExtension\Utils\PlaceholderUtils; |
| 6 | -use Ciandt\Behat\PlaceholdersExtension\PlaceholderContainer\PlaceholderContainer; |
|
| 7 | 6 | use Ciandt\Behat\PlaceholdersExtension\Exception\MissingSectionException; |
| 8 | 7 | use Ciandt\Behat\PlaceholdersExtension\Exception\UndefinedPlaceholderException; |
| 9 | 8 | use Exception; |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | |
| 72 | 72 | private function getFilePath($key) |
| 73 | 73 | { |
| 74 | - if (key_exists($key, $this->configs)) { |
|
| 74 | + if (key_exists($key, $this->configs)) { |
|
| 75 | 75 | return $this->configs[$key]['path']; |
| 76 | 76 | } |
| 77 | 77 | return null; |
@@ -87,14 +87,14 @@ discard block |
||
| 87 | 87 | $this->environment = $environment; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - private function getScenarioTags(){ |
|
| 90 | + private function getScenarioTags() { |
|
| 91 | 91 | return $this->beforeScenarioSubscriber->getScenarioTags(); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | private function replaceRecursively($placeholder, $replaced = array()) |
| 95 | 95 | { |
| 96 | 96 | // if the current placeholder was already replaced before, this is a cyclic dependecy |
| 97 | - if (in_array($placeholder, $replaced)){ |
|
| 97 | + if (in_array($placeholder, $replaced)) { |
|
| 98 | 98 | $tree = implode('>', $replaced); |
| 99 | 99 | throw new Exception("Cyclic placeholder dependecy detected. Trying to replace $placeholder again when already replaced: $tree"); |
| 100 | 100 | } |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | |
| 118 | 118 | // Then look in the placeholder files |
| 119 | - if ($replacement === null && $configTag !== false ) { |
|
| 119 | + if ($replacement === null && $configTag !== false) { |
|
| 120 | 120 | $section = PlaceholderUtils::getSectionKey($configTag); |
| 121 | 121 | $placeholders = $this->getSectionPlaceholders($configKey, $section); |
| 122 | 122 | $replacement = $this->recursiveReplacementSearch($keys, $placeholders); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if ($replacement === null && $configTag !== false){ |
|
| 125 | + if ($replacement === null && $configTag !== false) { |
|
| 126 | 126 | $configPath = $this->getFilePath($configKey); |
| 127 | 127 | $treePosition = "$configPath>$section>placeholders"; |
| 128 | 128 | throw new UndefinedPlaceholderException("No $placeholder replacement was defined on runtime or on $treePosition>$placeholder for variant $variant and environment $environment"); |
@@ -34,6 +34,9 @@ |
||
| 34 | 34 | return $string; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | + /** |
|
| 38 | + * @param PlaceholdersRepository $repository |
|
| 39 | + */ |
|
| 37 | 40 | public static function transformArgument($argument, $repository) { |
| 38 | 41 | if (is_string($argument)) { |
| 39 | 42 | return self::replaceStringPlaceholders($argument, $repository); |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | /** |
| 15 | 15 | * |
| 16 | 16 | */ |
| 17 | - class RuntimePlaceholdersTransformation extends RuntimeCallee implements PlaceholdersTransformation { |
|
| 17 | + class RuntimePlaceholdersTransformation extends RuntimeCallee implements PlaceholdersTransformation { |
|
| 18 | 18 | |
| 19 | 19 | public function __toString() { |
| 20 | 20 | return 'UserDefinedPlaceholderTransform'; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | if ($argument instanceof PyStringNode) { |
| 43 | 43 | $strings = $argument->getStrings(); |
| 44 | - foreach ($strings as &$string){ |
|
| 44 | + foreach ($strings as &$string) { |
|
| 45 | 45 | self::replaceStringPlaceholders($string, $repository); |
| 46 | 46 | } |
| 47 | 47 | return new PyStringNode($strings, $argument->getLine()); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - private static function replaceTablePlaceholders(&$item, $key, $repository){ |
|
| 57 | + private static function replaceTablePlaceholders(&$item, $key, $repository) { |
|
| 58 | 58 | $item = self::replaceStringPlaceholders($item, $repository); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | namespace Ciandt\Behat\PlaceholdersExtension\Transformation; |
| 5 | 5 | |
| 6 | -use Behat\Behat\Definition\Call\DefinitionCall; |
|
| 7 | 6 | use Behat\Gherkin\Node\PyStringNode; |
| 8 | 7 | use Behat\Gherkin\Node\TableNode; |
| 9 | 8 | use Behat\Testwork\Call\RuntimeCallee; |