Issues (15)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Parameter/Parameter.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of the GestPayWS library.
5
 *
6
 * (c) Manuel Dalla Lana <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EndelWar\GestPayWS\Parameter;
13
14
use InvalidArgumentException;
15
16
/**
17
 * Class Parameter
18
 * @package EndelWar\GestPayWS\Parameter
19
 */
20
abstract class Parameter implements \ArrayAccess
21
{
22
    protected $parameters = array();
23
    protected $parametersName = array();
24
    protected $mandatoryParameters = array();
25
26
    /**
27
     * @param array $parameters
28
     */
29 38
    public function __construct(array $parameters = array())
30
    {
31 38
        foreach ($this->parametersName as $parameterName) {
32 38
            $this->set($parameterName, null);
33 38
        }
34 38
        if (!empty($parameters)) {
35 9
            $this->fromArray($parameters);
36 9
        }
37 38
    }
38
39
    /**
40
     * @param string $key
41
     * @param mixed $value
42
     */
43 38 View Code Duplication
    public function set($key, $value)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45 38
        if (!in_array($key, $this->parametersName, true)) {
46 1
            throw new InvalidArgumentException(sprintf('%s is not a valid parameter name.', $key));
47
        }
48 38
        $this->parameters[$key] = $value;
49 38
    }
50
51
    /**
52
     * @param string $key
53
     *
54
     * @return mixed|null The value at the specified index or null.
55
     */
56 16
    public function get($key)
57
    {
58 16
        if (array_key_exists($key, $this->parameters)) {
59 13
            return $this->parameters[$key];
60
        }
61
62 3
        return;
63
    }
64
65
    /**
66
     * @param array $array
67
     */
68 11
    public function fromArray($array)
69
    {
70 11
        foreach ($array as $key => $value) {
71 11
            $this->set($key, $value);
72 11
        }
73 11
    }
74
75
    /**
76
     * @return array
77
     */
78 3
    public function toArray()
79
    {
80 3
        return $this->parameters;
81
    }
82
83
    /**
84
     * @return bool
85
     */
86 6
    public function areAllMandatoryParametersSet()
87
    {
88 6
        foreach ($this->mandatoryParameters as $param) {
89 6
            if (!isset($this->$param)) {
90 3
                return false;
91
            }
92 3
        }
93
94 3
        return true;
95
    }
96
97
    /**
98
     * Returns whether the requested index exists
99
     *
100
     * @param string $key
101
     *
102
     * @return bool
103
     */
104 1
    public function offsetExists($key)
105
    {
106 1
        return array_key_exists($key, $this->parameters);
107
    }
108
109
    /**
110
     * Returns the value at the specified index
111
     *
112
     * @param string $key The index with the value.
113
     *
114
     * @return mixed|null The value at the specified index or null.
115
     */
116 4
    public function offsetGet($key)
117
    {
118 4
        return $this->get($key);
119
    }
120
121
    /**
122
     * Sets the value at the specified index to $value
123
     *
124
     * @param string $key The index being set.
125
     * @param mixed $value The new value for the index
126
     */
127 2
    public function offsetSet($key, $value)
128
    {
129 2
        $this->set($key, $value);
130 2
    }
131
132
    /**
133
     * Unsets the value at the specified index
134
     *
135
     * @param string $key
136
     */
137 1
    public function offsetUnset($key)
138
    {
139 1
        unset($this->parameters[$key]);
140 1
    }
141
142
    /**
143
     * Magic getter, calls getXXX if exists.
144
     *
145
     * @param string $key
146
     *
147
     * @return mixed
148
     */
149 6 View Code Duplication
    public function __get($key)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
150
    {
151 6
        $getter = 'get' . $this->classify($key);
152 6
        if (method_exists($this, $getter)) {
153 1
            return call_user_func(array($this, $getter));
154
        }
155
156 6
        return $this->get($key);
157
    }
158
159
    /**
160
     * Magic setter, calls getXXX if exists.
161
     * @param $key
162
     * @param $value
163
     *
164
     * @return mixed
165
     */
166 1 View Code Duplication
    public function __set($key, $value)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
167
    {
168 1
        $setter = 'set' . $this->classify($key);
169 1
        if (method_exists($this, $setter)) {
170
            return call_user_func_array(array($this, $setter), array($value));
171
        }
172 1
        $this->set($key, $value);
173 1
    }
174
175
    /**
176
     * Converts a string into a CamelCase word.
177
     *
178
     * @param string $string The string to classify.
179
     *
180
     * @return string The classified word.
181
     */
182 6
    private function classify($string)
183
    {
184 6
        return str_replace(' ', '', ucwords(strtr($string, '_-', ' ')));
185
    }
186
187
    /**
188
     * Returns whether the requested index exists
189
     *
190
     * @param string $key
191
     *
192
     * @return bool
193
     */
194 6
    public function __isset($key)
195
    {
196 6
        return isset($this->parameters[$key]);
197
    }
198
199
    /**
200
     * Unsets the value at the specified index
201
     *
202
     * @param string $key
203
     */
204 1
    public function __unset($key)
205
    {
206 1
        unset($this->parameters[$key]);
207 1
    }
208
}
209