SummaryCleaner   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 29
c 1
b 0
f 0
ccs 0
cts 11
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A clean() 0 8 1
1
<?php
2
/**
3
 * AnimeDb package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 * @license   http://opensource.org/licenses/GPL-3.0 GPL v3
8
 */
9
namespace AnimeDb\Bundle\AniDbFillerBundle\Service;
10
11
use AnimeDb\Bundle\AniDbBrowserBundle\Service\Browser;
12
13
class SummaryCleaner
14
{
15
    /**
16
     * @var Browser
17
     */
18
    protected $browser;
19
20
    /**
21
     * @param Browser $browser
22
     */
23
    public function __construct(Browser $browser)
24
    {
25
        $this->browser = $browser;
26
    }
27
28
    /**
29
     * @param string $string
30
     *
31
     * @return string
32
     */
33
    public function clean($string)
34
    {
35
        $reg = '#'.preg_quote($this->browser->getHost()).'/ch\d+ \[([^\]]+)\]#';
36
        $string = preg_replace($reg, '$1', $string);
37
        $string = preg_replace('/\[[^\[\]]+\]/', '', $string); // remove BB tags
38
39
        return $string;
40
    }
41
}
42