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

MailToHighLighter::replaceMailTo()   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 MailToHighLighter {
6
7
    private $searchArray = array('/([a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})/');
8
    private $replaceArray = array('<a href="mailto:$1">$1</a>');
9
10
    /**
11
     * 
12
     * @param string $content
13
     * @return string
14
     */
15
    public function replaceMailTo($content) {
16
17
        if (!empty($content)) {
18
            $processedString = preg_replace($this->searchArray, $this->replaceArray, $content);
19
            return $processedString;
20
        }
21
    }
22
23
}
24