LinkHighLighter::replaceWebLinks()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace LinkEmailHighLighter\src\Services;
4
5
class LinkHighLighter {
6
7
    /**
8
     * 
9
     * @param string $content
10
     * @return string
11
     */
12
    public static function replaceWebLinks($content) {
13
14
        if (!empty($content)) {
15
            $processedString = preg_replace('/(^|[^"])(((f|ht){1}(tp|tps):\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', '\\1<a href="\\2" target="_blank">\\2</a>', $content);
16
            return $processedString;
17
        }
18
    }
19
20
}
21