Completed
Push — master ( e2d679...4c248a )
by NexusLink
03:31
created

LinkHighLighter::replaceWebLinks()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
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
    private $regex = '/(^|[^"])(((f|ht){1}(tp|tps):\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i';
8
    private $replaceToString = '\\1<a href="\\2" target="_blank">\\2</a>';
9
10
    /**
11
     * 
12
     * @param string $content
13
     * @return string
14
     */
15
    public function replaceWebLinks($content) {
16
17
        if (!empty($content)) {
18
            $processedString = preg_replace($this->regex, $this->replaceToString, $content);
19
            return $processedString;
20
        }
21
    }
22
23
}
24