GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Param::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Pimf
4
 *
5
 * @copyright Copyright (c)  Gjero Krsteski (http://krsteski.de)
6
 * @license   http://opensource.org/licenses/MIT MIT License
7
 */
8
9
namespace Pimf;
10
11
/**
12
 * @package Pimf
13
 * @author  Gjero Krsteski <[email protected]>
14
 */
15
class Param
16
{
17
    /**
18
     * @var \ArrayObject|null
19
     */
20
    protected $data = null;
21
22
    /**
23
     * @param array $data
24
     */
25
    public function __construct(array $data = array())
26
    {
27
        $this->data = new \ArrayObject($data, \ArrayObject::STD_PROP_LIST + \ArrayObject::ARRAY_AS_PROPS);
28
    }
29
30
    /**
31
     * @return array
32
     */
33
    public function getAll()
34
    {
35
        return (array)$this->data->getArrayCopy();
36
    }
37
38
    /**
39
     * @param string      $index
40
     * @param null|string $defaultValue
41
     * @param bool        $filtered If you trust foreign input introduced to your PHP code - set to FALSE!
42
     *
43
     * @return mixed
44
     */
45
    public function get($index, $defaultValue = null, $filtered = true)
46
    {
47
        if ($this->data->offsetExists($index)) {
48
49
            if ($filtered === true) {
50
                // pretty high-level filtering here...
51
                return self::filter($this->data->offsetGet($index));
52
            }
53
54
            return $this->data->offsetGet($index);
55
        }
56
57
        return $defaultValue;
58
    }
59
60
    /**
61
     * Never ever (ever) trust foreign input introduced to your PHP code!
62
     *
63
     * @param mixed $rawData
64
     *
65
     * @return mixed
66
     */
67
    public static function filter($rawData)
68
    {
69
        return is_array($rawData)
70
71
            ? array_map(
72
                function ($value) {
73
                    return \Pimf\Util\Character\Clean::xss($value);
74
                }, $rawData
75
            )
76
77
            : \Pimf\Util\Character\Clean::xss($rawData);
78
    }
79
}
80