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

LinkHighLighter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A replaceWebLinks() 0 7 2
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