Code Duplication    Length = 13-14 lines in 2 locations

src/Transformers/MarkdownTansformer.php 1 location

@@ 32-44 (lines=13) @@
29
     * @param string $string
30
     * @return void
31
     */
32
    private function transform($string)
33
    {
34
35
        $string = preg_replace("/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/", "[$0]($0) ", $string);
36
37
        foreach (array_keys($this->tags) as $tagtype) {
38
            $tagconf = $this->tags[$tagtype];
39
            $string = preg_replace_callback('/\s+' . $this->tags[$tagtype]['prefix'] . '(\w+)/', function($matches) use ($tagconf) {
40
                return ' ' . trim($this->buildMarkdownLink($matches[1], trim($matches[0]), $tagconf));
41
            }, $string);
42
        }
43
        $this->formatted = $string;
44
    }
45
46
    /**
47
     * Builds the Mardown link replacement for the Markdown transformation.

src/Transformers/HtmlTransformer.php 1 location

@@ 32-45 (lines=14) @@
29
     * @param string $string
30
     * @return void
31
     */
32
    private function transform($string)
33
    {
34
35
        $string = preg_replace("/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/", "<a href=\"$0\">$0</a> ", $string);
36
37
        foreach (array_keys($this->tags) as $tagtype) {
38
            $tagconf = $this->tags[$tagtype];
39
            $string = preg_replace_callback('/\s+' . $this->tags[$tagtype]['prefix'] . '(\w+)/', function($matches) use ($tagconf) {
40
                return ' ' . trim($this->buildHtmlLink($matches[1], trim($matches[0]), $tagconf));
41
            }, $string);
42
        }
43
44
        $this->formatted = $string;
45
    }
46
47
    /**
48
     * Builds the HTML link replacement for the HTML transformation.