Code Duplication    Length = 18-18 lines in 4 locations

Core/Executor/HTTPExecutor.php 1 location

@@ 152-169 (lines=18) @@
149
     * @param string
150
     * @return string
151
     */
152
    protected function resolveReferencesInText($text)
153
    {
154
        // 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
155
        $regexp = substr($this->referenceResolver->getRegexp(), 1, -1);
156
        // NB: here we assume that all regexp resolvers give us a regexp with a very specific format...
157
        $regexp = '/\[' . preg_replace(array('/^\^/'), array('', ''), $regexp) . '[^]]+\]/';
158
159
        $count = preg_match_all($regexp, $text, $matches);
160
        // $matches[0][] will have the matched full string eg.: [reference:example_reference]
161
        if ($count) {
162
            foreach ($matches[0] as $referenceIdentifier) {
163
                $reference = $this->referenceResolver->getReferenceValue(substr($referenceIdentifier, 1, -1));
164
                $text = str_replace($referenceIdentifier, $reference, $text);
165
            }
166
        }
167
168
        return $text;
169
    }
170
171
    protected function resolveReferencesInTextRecursively($textOrArray)
172
    {

Core/Executor/MailExecutor.php 1 location

@@ 136-153 (lines=18) @@
133
     * @param string
134
     * @return string
135
     */
136
    protected function resolveReferencesInText($text)
137
    {
138
        // 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
139
        $regexp = substr($this->referenceResolver->getRegexp(), 1, -1);
140
        // NB: here we assume that all regexp resolvers give us a regexp with a very specific format...
141
        $regexp = '/\[' . preg_replace(array('/^\^/'), array('', ''), $regexp) . '[^]]+\]/';
142
143
        $count = preg_match_all($regexp, $text, $matches);
144
        // $matches[0][] will have the matched full string eg.: [reference:example_reference]
145
        if ($count) {
146
            foreach ($matches[0] as $referenceIdentifier) {
147
                $reference = $this->referenceResolver->getReferenceValue(substr($referenceIdentifier, 1, -1));
148
                $text = str_replace($referenceIdentifier, $reference, $text);
149
            }
150
        }
151
152
        return $text;
153
    }
154
}
155

Core/Executor/ProcessExecutor.php 1 location

@@ 143-160 (lines=18) @@
140
     * @param string
141
     * @return string
142
     */
143
    protected function resolveReferencesInText($text)
144
    {
145
        // 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
146
        $regexp = substr($this->referenceResolver->getRegexp(), 1, -1);
147
        // NB: here we assume that all regexp resolvers give us a regexp with a very specific format...
148
        $regexp = '/\[' . preg_replace(array('/^\^/'), array('', ''), $regexp) . '[^]]+\]/';
149
150
        $count = preg_match_all($regexp, $text, $matches);
151
        // $matches[0][] will have the matched full string eg.: [reference:example_reference]
152
        if ($count) {
153
            foreach ($matches[0] as $referenceIdentifier) {
154
                $reference = $this->referenceResolver->getReferenceValue(substr($referenceIdentifier, 1, -1));
155
                $text = str_replace($referenceIdentifier, $reference, $text);
156
            }
157
        }
158
159
        return $text;
160
    }
161
}

Core/Executor/FileExecutor.php 1 location

@@ 360-377 (lines=18) @@
357
     * @param string $text
358
     * @return string
359
     */
360
    protected function resolveReferencesInText($text)
361
    {
362
        // 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
363
        $regexp = substr($this->referenceResolver->getRegexp(), 1, -1);
364
        // NB: here we assume that all regexp resolvers give us a regexp with a very specific format...
365
        $regexp = '/\[' . preg_replace(array('/^\^/'), array('', ''), $regexp) . '[^]]+\]/';
366
367
        $count = preg_match_all($regexp, $text, $matches);
368
        // $matches[0][] will have the matched full string eg.: [reference:example_reference]
369
        if ($count) {
370
            foreach ($matches[0] as $referenceIdentifier) {
371
                $reference = $this->referenceResolver->getReferenceValue(substr($referenceIdentifier, 1, -1));
372
                $text = str_replace($referenceIdentifier, $reference, $text);
373
            }
374
        }
375
376
        return $text;
377
    }
378
}
379