Purifier   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A clean() 0 13 3
1
<?php
2
3
namespace Realshadow\RequestDeserializer\Validation;
4
5
/**
6
 * Extension of Purifier to make it type aware
7
 *
8
 * @package Realshadow\RequestDeserializer\Validation
9
 * @author Lukáš Homza <[email protected]>
10
 */
11
class Purifier extends \Mews\Purifier\Purifier
12
{
13
14
    /**
15
     * @inheritdoc
16
     */
17
    public function clean($dirty, $config = null)
18
    {
19
        if (is_array($dirty)) {
20
            $output = array_map(function ($item) use ($config) {
21
                return $this->clean($item, $config);
22
            }, $dirty);
23
        } else {
24
            # -- the htmlpurifier uses replace instead of merge, so we merge
25
            $output = is_string($dirty) ? $this->purifier->purify($dirty, $this->getConfig($config)) : $dirty;
0 ignored issues
show
Documentation introduced by
$this->getConfig($config) is of type array, but the function expects a object<HTMLPurifier_Config>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
26
        }
27
28
        return $output;
29
    }
30
31
}
32