Filter::filter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Codeat3\FoaasClient\ResponseFilters;
4
5
class Filter implements FoaasFilter
6
{
7
    protected $decencyLevelMap = [
8
        'low' => [
9
            'search' => 'fuck',
10
            'replace'=> 'f*ck',
11
        ],
12
        'medium' => [
13
            'search' => 'fuck',
14
            'replace'=> 'f*#k',
15
        ],
16
        'high' => [
17
            'search' => 'fuck',
18
            'replace'=> 'f*#$',
19
        ],
20
        'extreme' => [
21
            'search' => 'fuck',
22
            'replace'=> '!*#$',
23
        ],
24
    ];
25
26
    protected $decencyLevel;
27
28
    public function __construct($decency)
29
    {
30
        $this->decencyLevel = $decency;
31
    }
32
33
    public function filter($response)
34
    {
35
        return str_ireplace($this->decencyLevelMap[$this->decencyLevel]['search'], $this->decencyLevelMap[$this->decencyLevel]['replace'], $response);
36
    }
37
}
38