StringTagAppendar::appendAround()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.2
cc 4
eloc 5
nc 2
nop 3
1
<?php
2
3
/*
4
 * This file is part of the Html Tag Appendar
5
 *
6
 * (c) Nexuslink Services
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace HtmlTagAppendar;
13
14
class StringTagAppendar {    
15
16
    /**
17
     * @param string $content
18
     * @param string $string
19
     * @param string $tag
20
     * 
21
     * @return string
22
     */
23
    public function appendAround($content, $string, $tag) {
24
        
25
        if(!empty($content) && !empty($string) && !empty($tag)) {
26
            $htmltag = str_replace('<', '', str_replace('>', '', $tag));
27
            
28
            return preg_replace(array('/'.$string.'/i'), array('<'.$htmltag.'>'.$string.'</'.$htmltag.'>'), $content);
29
        }
30
        
31
        return $content;
32
    }
33
    
34
}
35