Code Duplication    Length = 18-18 lines in 4 locations

Core/Executor/HTTPExecutor.php 1 location

@@ 148-165 (lines=18) @@
145
     * @param string
146
     * @return string
147
     */
148
    protected function resolveReferencesInText($text)
149
    {
150
        // we need to alter the regexp we get from the resolver, as it will be used to match parts of text, not the whole string
151
        $regexp = substr($this->referenceResolver->getRegexp(), 1, -1);
152
        // NB: here we assume that all regexp resolvers give us a regexp with a very specific format...
153
        $regexp = '/\[' . preg_replace(array('/^\^/'), array('', ''), $regexp) . '[^]]+\]/';
154
155
        $count = preg_match_all($regexp, $text, $matches);
156
        // $matches[0][] will have the matched full string eg.: [reference:example_reference]
157
        if ($count) {
158
            foreach ($matches[0] as $referenceIdentifier) {
159
                $reference = $this->referenceResolver->getReferenceValue(substr($referenceIdentifier, 1, -1));
160
                $text = str_replace($referenceIdentifier, $reference, $text);
161
            }
162
        }
163
164
        return $text;
165
    }
166
167
    protected function resolveReferencesInTextRecursively($textOrArray)
168
    {

Core/Executor/MailExecutor.php 1 location

@@ 132-149 (lines=18) @@
129
     * @param string
130
     * @return string
131
     */
132
    protected function resolveReferencesInText($text)
133
    {
134
        // we need to alter the regexp we get from the resolver, as it will be used to match parts of text, not the whole string
135
        $regexp = substr($this->referenceResolver->getRegexp(), 1, -1);
136
        // NB: here we assume that all regexp resolvers give us a regexp with a very specific format...
137
        $regexp = '/\[' . preg_replace(array('/^\^/'), array('', ''), $regexp) . '[^]]+\]/';
138
139
        $count = preg_match_all($regexp, $text, $matches);
140
        // $matches[0][] will have the matched full string eg.: [reference:example_reference]
141
        if ($count) {
142
            foreach ($matches[0] as $referenceIdentifier) {
143
                $reference = $this->referenceResolver->getReferenceValue(substr($referenceIdentifier, 1, -1));
144
                $text = str_replace($referenceIdentifier, $reference, $text);
145
            }
146
        }
147
148
        return $text;
149
    }
150
}
151

Core/Executor/ProcessExecutor.php 1 location

@@ 139-156 (lines=18) @@
136
     * @param string
137
     * @return string
138
     */
139
    protected function resolveReferencesInText($text)
140
    {
141
        // we need to alter the regexp we get from the resolver, as it will be used to match parts of text, not the whole string
142
        $regexp = substr($this->referenceResolver->getRegexp(), 1, -1);
143
        // NB: here we assume that all regexp resolvers give us a regexp with a very specific format...
144
        $regexp = '/\[' . preg_replace(array('/^\^/'), array('', ''), $regexp) . '[^]]+\]/';
145
146
        $count = preg_match_all($regexp, $text, $matches);
147
        // $matches[0][] will have the matched full string eg.: [reference:example_reference]
148
        if ($count) {
149
            foreach ($matches[0] as $referenceIdentifier) {
150
                $reference = $this->referenceResolver->getReferenceValue(substr($referenceIdentifier, 1, -1));
151
                $text = str_replace($referenceIdentifier, $reference, $text);
152
            }
153
        }
154
155
        return $text;
156
    }
157
}

Core/Executor/FileExecutor.php 1 location

@@ 298-315 (lines=18) @@
295
     * @param string
296
     * @return string
297
     */
298
    protected function resolveReferencesInText($text)
299
    {
300
        // we need to alter the regexp we get from the resolver, as it will be used to match parts of text, not the whole string
301
        $regexp = substr($this->referenceResolver->getRegexp(), 1, -1);
302
        // NB: here we assume that all regexp resolvers give us a regexp with a very specific format...
303
        $regexp = '/\[' . preg_replace(array('/^\^/'), array('', ''), $regexp) . '[^]]+\]/';
304
305
        $count = preg_match_all($regexp, $text, $matches);
306
        // $matches[0][] will have the matched full string eg.: [reference:example_reference]
307
        if ($count) {
308
            foreach ($matches[0] as $referenceIdentifier) {
309
                $reference = $this->referenceResolver->getReferenceValue(substr($referenceIdentifier, 1, -1));
310
                $text = str_replace($referenceIdentifier, $reference, $text);
311
            }
312
        }
313
314
        return $text;
315
    }
316
}
317