Issues (150)

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/Data/StoreCollection.php (5 issues)

Labels

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
namespace PEIP\Data;
4
5
/*
6
 * This file is part of the PEIP package.
7
 * (c) 2009-2016 Timo Michna <timomichna/yahoo.de>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
/**
14
 * StoreCollection
15
 * Class to act as a namespaced store for arbitrary values.
16
 *
17
 * @author Timo Michna <timomichna/yahoo.de>
18
 * @extends \PEIP\Data\InternalStoreAbstract
19
 * @implements \PEIP\INF\Data\StoreCollection
20
 */
21
class StoreCollection extends \PEIP\Data\InternalStoreAbstract implements \PEIP\INF\Data\StoreCollection
22
{
23
    protected $factory,
24
        $stores;
25
26
    /**
27
     * constructor.
28
     *
29
     * @param \PEIP\INF\Factory\DedicatedFactory $factory a factory instance to create new stores
30
     *
31
     * @return
32
     */
33
    public function __construct(\PEIP\INF\Factory\DedicatedFactory $factory)
34
    {
35
        $this->factory = $factory;
36
    }
37
38
    /**
39
     * Returns a \PEIP\INF\Data\Store instance for a given namespace.
40
     * Creates a new \PEIP\INF\Data\Store instance if none is allerady set for given namespace.
41
     *
42
     * @param string $namespace the namespace to get the store for
43
     *
44
     * @return \PEIP\INF\Data\Store a store for given namespace
45
     */
46
    protected function getStoreOrCreate($namespace)
47
    {
48
        if (!$this->hasPrivateValue($namespace)) {
0 ignored issues
show
The method hasPrivateValue() does not seem to exist on object<PEIP\Data\StoreCollection>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
            $store = $this->factory->build();
50
            if ($store instanceof \PEIP\INF\Data\Store) {
51
                $this->setPrivateValue($namespace, $store);
0 ignored issues
show
The method setPrivateValue() does not seem to exist on object<PEIP\Data\StoreCollection>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
            } else {
53
                throw new \Exception('Could not build Instance of \PEIP\INF\Data\Store from factory.');
54
            }
55
        }
56
57
        return $this->getPrivateValue($namespace);
0 ignored issues
show
The method getPrivateValue() does not seem to exist on object<PEIP\Data\StoreCollection>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
58
    }
59
60
    /**
61
     * Sets all values for a namespace as key/value pairs array.
62
     *
63
     * @param string $namespace the namspace to set values for
64
     * @param array  $values    key/value pairs to store
65
     *
66
     * @return
67
     */
68
    public function setValues($namespace, array $values)
69
    {
70
        $this->getStoreOrCreate($namespace)->setValues($values);
71
    }
72
73
    /**
74
     * Adds values for a namespace as key/value pairs array.
75
     * Overwrites value for a key if allready has been set.
76
     *
77
     * @param string $namespace the namspace to add values to
78
     * @param $values
79
     *
80
     * @return
81
     */
82
    public function addValues($namespace, array $values)
83
    {
84
        $this->getStoreOrCreate($namespace)->addValues($values);
85
    }
86
87
    /**
88
     * returns all values for a namespace as key/value pairs.
89
     *
90
     * @param string $namespace the namspace to return values for
91
     *
92
     * @return array stored key/value pairs
93
     */
94
    public function getValues($namespace)
95
    {
96
        $this->getStoreOrCreate($namespace)->getValues();
97
    }
98
99
    /**
100
     * Returns the value for a given key on a given namespace.
101
     *
102
     * @param string $namespace the namspace to return value for
103
     * @param string $key       the key to return value for
104
     *
105
     * @return mixed value for the given key on the given namespace
106
     */
107
    public function getValue($namespace, $key)
108
    {
109
        $this->getStoreOrCreate($namespace)->getValue($key);
110
    }
111
112
    /**
113
     * Stores the value for a given key on a given namespace.
114
     *
115
     * @param string $namespace the namspace to store a value for
116
     * @param string $key       key to store value for
117
     * @param mixed  $value     the value to store
118
     *
119
     * @return
120
     */
121
    public function setValue($namespace, $key, $value)
122
    {
123
        $this->getStoreOrCreate($namespace)->setValues($values);
0 ignored issues
show
The variable $values does not exist. Did you mean $value?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
124
    }
125
126
    /**
127
     * Checks wether a value is stored for given key on a given namespace.
128
     *
129
     * @param $namespace the namespace to look for a value
130
     * @param string $key the key to look for a value
131
     *
132
     * @return
133
     */
134
    public function hasValue($namespace, $key)
135
    {
136
        $this->getStoreOrCreate($namespace)->hasValue($key);
137
    }
138
139
    /**
140
     * Removes the value for a given key on a given namespace.
141
     *
142
     * @param string $namespace the namespace to remove the value from
143
     * @param string $key       the key to remove the value from
144
     *
145
     * @return
146
     */
147
    public function deleteValue($namespace, $key)
148
    {
149
        $this->getStoreOrCreate($namespace)->setValues($values);
0 ignored issues
show
The variable $values does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
150
    }
151
152
    /**
153
     * Sets a store instance (\PEIP\INF\Data\Store) for a given namespace.
154
     *
155
     * @param string               $namespace the namespace to set the store for
156
     * @param \PEIP\INF\Data\Store $store     the store instance to register for the namespace
157
     *
158
     * @return
159
     */
160
    public function setStore($namespace, \PEIP\INF\Data\Store $store)
161
    {
162
        $this->setInternalValue($namespace, $store);
163
    }
164
165
    /**
166
     * returns the store instance for a given namespace.
167
     *
168
     * @param string $namespace the namespace to return the store for
169
     *
170
     * @return \PEIP\INF\Data\Store store instance for given namespace (if set)
171
     */
172
    public function getStore($namespace)
173
    {
174
        $this->getInternalValue($namespace);
175
    }
176
177
    /**
178
     * Checks wether a store has been registered for a given namespace.
179
     *
180
     * @param string $namespace the namespace to check for a store instance
181
     *
182
     * @return bool wether a store has been registered for the given namespace
183
     */
184
    public function hasStore($namespace)
185
    {
186
        return $this->hasInternalValue($namespace);
187
    }
188
189
    /**
190
     * Unregisters the store for a given namespace.
191
     *
192
     * @param string $namespace the namespace to ungegister the store for
193
     *
194
     * @return
195
     */
196
    public function deleteStore($namespace)
197
    {
198
        return $this->deleteInternalValue($namespace);
199
    }
200
}
201