SummaryCleaner::clean()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
c 1
b 0
f 0
ccs 0
cts 7
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 2
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