1 | <?php |
||
26 | final class RepositoryStepTokensReplacer implements StepTokensReplacer |
||
27 | { |
||
28 | /** |
||
29 | * @var TokensReplacementsRepository |
||
30 | */ |
||
31 | private $repository; |
||
32 | /** |
||
33 | * @var CallCenter |
||
34 | */ |
||
35 | private $callCenter; |
||
36 | |||
37 | /** |
||
38 | * Initializes tokens replacer. |
||
39 | * |
||
40 | * @param TokensReplacementsRepository $repository |
||
41 | * @param CallCenter $callCenter |
||
42 | */ |
||
43 | public function __construct( |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | public function replaceTokens(Environment $environment, FeatureNode $feature, StepNode $step) |
||
68 | |||
69 | /** |
||
70 | * Replace tokens in text with values. |
||
71 | * |
||
72 | * @param string $value |
||
73 | * Text value to replace the tokens in. |
||
74 | * @param TokensReplacement[] $tokens_replacements |
||
75 | * Tokens replacement callees read. |
||
76 | * @param StepNode $step |
||
77 | * Step node to be modified. |
||
78 | * @param Environment $environment |
||
79 | * Environment from to read. |
||
80 | * @return string |
||
81 | * Processed step text with replaced tokens. |
||
82 | * @throws null |
||
83 | */ |
||
84 | protected function replaceTokensText($value, $tokens_replacements, StepNode $step, Environment $environment) |
||
102 | |||
103 | /** |
||
104 | * Replaces tokens in arguments with values. |
||
105 | * |
||
106 | * @param ArgumentInterface[] $arguments |
||
107 | * |
||
108 | * @return ArgumentInterface[] |
||
109 | */ |
||
110 | protected function replaceTokensArguments(array $arguments, array $tokens_replacements, StepNode $step, Environment $environment) |
||
123 | |||
124 | |||
125 | /** |
||
126 | * Replaces tokens in table with values. |
||
127 | * |
||
128 | * @param TableNode $argument |
||
129 | * |
||
130 | * @return TableNode |
||
131 | */ |
||
132 | protected function replaceTokensArgumentTable(TableNode $argument, array $tokens_replacements, StepNode $step, Environment $environment) |
||
143 | |||
144 | /** |
||
145 | * Replaces tokens in PyString with values. |
||
146 | * |
||
147 | * @param PyStringNode $argument |
||
148 | * |
||
149 | * @return PyStringNode |
||
150 | */ |
||
151 | protected function replaceTokensArgumentPyString(PyStringNode $argument, array $tokens_replacements, StepNode $step, Environment $environment) |
||
160 | |||
161 | /** |
||
162 | * Checks if pattern tokens replacement is applicable. |
||
163 | * |
||
164 | * @param string $value |
||
165 | * String to replace tokens. |
||
166 | * @param TokensReplacement $tokensReplacement |
||
167 | * Token replacement callee. |
||
168 | * @param $matches |
||
169 | * Array of matches identified after |
||
170 | * @return bool |
||
171 | * TRUE if text matched the pattern, FALSE otherwise. |
||
172 | */ |
||
173 | private function isApplicableTokensReplacement($value, TokensReplacement $tokensReplacement, &$matches) |
||
192 | |||
193 | /** |
||
194 | * Executes tokens replacement. |
||
195 | * |
||
196 | * @param string $value |
||
197 | * @param Environment $environment |
||
198 | * @param StepNode $step |
||
199 | * @param TokensReplacement $tokensReplacement |
||
200 | * |
||
201 | * @return mixed |
||
202 | * Return value from the callee callable. |
||
203 | */ |
||
204 | private function execute($value, Environment $environment, StepNode $step, TokensReplacement $tokensReplacement) |
||
221 | } |
||
222 |